Change git_revparse to output git_object pointers

This will probably prevent many lookup/free
operations in calling code.
This commit is contained in:
Ben Straub
2013-04-15 12:00:04 -07:00
parent 2ebc3c66c2
commit 299a224be1
10 changed files with 54 additions and 66 deletions
+2 -4
View File
@@ -15,12 +15,10 @@ static int resolve_to_tree(
git_repository *repo, const char *identifier, git_tree **tree)
{
int err = 0;
git_oid oid;
git_object *obj = NULL;
if (git_revparse(&oid, NULL, NULL, repo, identifier) < 0 ||
git_object_lookup(&obj, repo, &oid, GIT_OBJ_ANY) < 0)
return GIT_ENOTFOUND;
if ((err =git_revparse(&obj, NULL, NULL, repo, identifier)) < 0)
return err;
switch (git_object_type(obj)) {
case GIT_OBJ_TREE:
+10 -6
View File
@@ -25,16 +25,18 @@ static int push_commit(git_revwalk *walk, git_oid *oid, int hide)
static int push_spec(git_repository *repo, git_revwalk *walk, const char *spec, int hide)
{
int error;
git_oid oid;
git_object *obj;
if ((error = git_revparse(&oid, NULL, NULL, repo, spec)))
if ((error = git_revparse(&obj, NULL, NULL, repo, spec)) < 0)
return error;
return push_commit(walk, &oid, hide);
error = push_commit(walk, git_object_id(obj), hide);
git_object_free(obj);
return error;
}
static int push_range(git_repository *repo, git_revwalk *walk, const char *range, int hide)
{
git_oid left, right;
git_object left, right;
git_revparse_flag_t flags;
int error = 0;
@@ -45,11 +47,13 @@ static int push_range(git_repository *repo, git_revwalk *walk, const char *range
return GIT_EINVALIDSPEC;
}
if ((error = push_commit(walk, &left, !hide)))
if ((error = push_commit(walk, git_object_id(left), !hide)))
goto out;
error = push_commit(walk, &right, hide);
error = push_commit(walk, git_object_id(right), hide);
out:
git_object_free(left);
git_object_free(right);
return error;
}