summaryrefslogtreecommitdiff
path: root/src/revwalk.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-04-13 10:33:14 -0700
committerRussell Belfer <rb@github.com>2012-04-17 10:44:50 -0700
commitf201d613a80f7ad6f54d90eb7a7a0d8b8c72676b (patch)
treec3cd8f0eee145f40b640519e06ae628cdb942eb3 /src/revwalk.c
parent1a6e8f8a54eea1159a950cd8a49cedae3699ff9a (diff)
downloadlibgit2-f201d613a80f7ad6f54d90eb7a7a0d8b8c72676b.tar.gz
Add git_reference_lookup_oid and lookup_resolved
Adds a new public reference function `git_reference_lookup_oid` that directly resolved a reference name to an OID without returning the intermediate `git_reference` object (hence, no free needed). Internally, this adds a `git_reference_lookup_resolved` function that combines looking up and resolving a reference. This allows us to be more efficient with memory reallocation. The existing `git_reference_lookup` and `git_reference_resolve` are reimplmented on top of the new utility and a few places in the code are changed to use one of the two new functions.
Diffstat (limited to 'src/revwalk.c')
-rw-r--r--src/revwalk.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index c2c098cf8..2d815b96a 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -492,21 +492,12 @@ int git_revwalk_hide(git_revwalk *walk, const git_oid *oid)
static int push_ref(git_revwalk *walk, const char *refname, int hide)
{
- git_reference *ref, *resolved;
- int error;
+ git_oid oid;
- if (git_reference_lookup(&ref, walk->repo, refname) < 0)
+ if (git_reference_lookup_oid(&oid, walk->repo, refname) < 0)
return -1;
- error = git_reference_resolve(&resolved, ref);
- git_reference_free(ref);
- if (error < 0)
- return -1;
-
- error = push_commit(walk, git_reference_oid(resolved), hide);
- git_reference_free(resolved);
-
- return error;
+ return push_commit(walk, &oid, hide);
}
struct push_cb_data {