mirror of
https://git.proxmox.com/git/libgit2
synced 2026-08-26 18:28:53 +00:00
Change git_revparse to output git_object pointers
This will probably prevent many lookup/free operations in calling code.
This commit is contained in:
+2
-4
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user