Fix the retarded object interdependency system

It's no longer retarded. All object interdependencies are stored as OIDs
instead of actual objects. This should be hundreds of times faster,
specially on big repositories. Heck, who knows, maye it doesn't even
segfault -- wouldn't that be awesome?

What has changed on the API?

	`git_commit_parent`, `git_commit_tree`, `git_tag_target` now return
	their values through a pointer-to-pointer, and have an error code.

	`git_commit_set_tree` and `git_tag_set_target` now return an error
	code and may fail.

	`git_repository_free__no_gc` has been deprecated because it's
	stupid. Since there are no longer any interdependencies between
	objects, we don't need internal reference counting, and GC
	never fails or double-free's pointers.

	`git_object_close` now does a very sane thing: marks an object
	as unused. Closed objects will be eventually free'd from the
	object cache based on LRU. Please use `git_object_close` from
	the garbage collector `destroy` method on your bindings. It's
	100% safe.

	`git_repository_gc` is a new method that forces a garbage collector
	pass through the repo, to free as many LRU objects as possible.
	This is useful if we are running out of memory.
This commit is contained in:
Vicent Marti
2011-03-12 23:09:16 +02:00
parent 0057182807
commit 6b2a19418c
15 changed files with 187 additions and 268 deletions

View File

@@ -122,10 +122,11 @@ GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
/**
* Get the tree pointed to by a commit.
* @param tree_out pointer where to store the tree object
* @param commit a previously loaded commit.
* @return the tree of a commit
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(const git_tree *) git_commit_tree(git_commit *commit);
GIT_EXTERN(int) git_commit_tree(git_tree **tree_out, git_commit *commit);
/**
* Get the number of parents of this commit
@@ -137,11 +138,13 @@ GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
/**
* Get the specified parent of the commit.
*
* @param parent Pointer where to store the parent commit
* @param commit a previously loaded commit.
* @param n the position of the entry
* @return a pointer to the commit; NULL if out of bounds
* @param n the position of the parent (from 0 to `parentcount`)
* @return 0 on success; error code otherwise
*/
GIT_EXTERN(git_commit *) git_commit_parent(git_commit *commit, unsigned int n);
GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n);
/**
* Add a new parent commit to an existing commit
@@ -176,8 +179,9 @@ GIT_EXTERN(void) git_commit_set_author(git_commit *commit, const git_signature *
* Set the tree which is pointed to by a commit
* @param commit the commit object
* @param tree the new tree
* @param 0 on success; error code otherwise
*/
GIT_EXTERN(void) git_commit_set_tree(git_commit *commit, git_tree *tree);
GIT_EXTERN(int) git_commit_set_tree(git_commit *commit, git_tree *tree);
/** @} */
GIT_END_DECL