summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-04-15 12:00:04 -0700
committerBen Straub <bs@github.com>2013-04-15 12:00:04 -0700
commit299a224be16368dc36bef4dc3f5e711ce35300cd (patch)
tree5371b54270c4b84abd586c49d7eb06b80d3d4e7b /examples
parent2ebc3c66c292539786b6ec1538f740c5e444fe16 (diff)
downloadlibgit2-299a224be16368dc36bef4dc3f5e711ce35300cd.tar.gz
Change git_revparse to output git_object pointers
This will probably prevent many lookup/free operations in calling code.
Diffstat (limited to 'examples')
-rw-r--r--examples/diff.c6
-rw-r--r--examples/rev-list.c16
2 files changed, 12 insertions, 10 deletions
diff --git a/examples/diff.c b/examples/diff.c
index 6fa0fee52..a977abd3f 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -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:
diff --git a/examples/rev-list.c b/examples/rev-list.c
index 71a8180f7..1747f2041 100644
--- a/examples/rev-list.c
+++ b/examples/rev-list.c
@@ -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;
}