diff options
| author | Vicent Marti <tanoku@gmail.com> | 2013-04-15 23:18:24 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2013-04-15 23:18:24 +0200 |
| commit | d064c74794f51e759cd84648f84f2609d3283ecc (patch) | |
| tree | 8ec58c4678fbc85f0038bf3eff89d67b3879ead7 /examples | |
| parent | 77849ebf1e39126bcb9f1245423749d45d226022 (diff) | |
| parent | 201566539f38874b4e93c6a36593bd0d10e6352c (diff) | |
| download | libgit2-d064c74794f51e759cd84648f84f2609d3283ecc.tar.gz | |
Merge remote-tracking branch 'ben/unified-revparse' into development
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/Makefile | 2 | ||||
| -rw-r--r-- | examples/diff.c | 4 | ||||
| -rw-r--r-- | examples/rev-list.c | 24 |
3 files changed, 16 insertions, 14 deletions
diff --git a/examples/Makefile b/examples/Makefile index b306d4800..2c18731fd 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -3,7 +3,7 @@ CC = gcc CFLAGS = -g -I../include -I../src -Wall -Wextra -Wmissing-prototypes -Wno-missing-field-initializers LFLAGS = -L../build -lgit2 -lz -APPS = general showindex diff +APPS = general showindex diff rev-list all: $(APPS) diff --git a/examples/diff.c b/examples/diff.c index a153b493b..2ef405665 100644 --- a/examples/diff.c +++ b/examples/diff.c @@ -17,8 +17,8 @@ static int resolve_to_tree( int err = 0; git_object *obj = NULL; - if (git_revparse_single(&obj, repo, identifier) < 0) - return GIT_ENOTFOUND; + if ((err = git_revparse_single(&obj, 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 b7e466f9e..f309207b0 100644 --- a/examples/rev-list.c +++ b/examples/rev-list.c @@ -14,12 +14,12 @@ static void check_error(int error_code, const char *action) exit(1); } -static int push_commit(git_revwalk *walk, git_object *obj, int hide) +static int push_commit(git_revwalk *walk, const git_oid *oid, int hide) { if (hide) - return git_revwalk_hide(walk, git_object_id(obj)); + return git_revwalk_hide(walk, oid); else - return git_revwalk_push(walk, git_object_id(obj)); + return git_revwalk_push(walk, oid); } static int push_spec(git_repository *repo, git_revwalk *walk, const char *spec, int hide) @@ -27,27 +27,29 @@ static int push_spec(git_repository *repo, git_revwalk *walk, const char *spec, int error; git_object *obj; - if ((error = git_revparse_single(&obj, repo, spec))) + if ((error = git_revparse_single(&obj, repo, spec)) < 0) return error; - return push_commit(walk, obj, 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_object *left, *right; - int threedots; + git_revparse_flag_t flags; int error = 0; - if ((error = git_revparse_rangelike(&left, &right, &threedots, repo, range))) + if ((error = git_revparse(&left, &right, &flags, repo, range))) return error; - if (threedots) { + if (flags & GIT_REVPARSE_MERGE_BASE) { /* TODO: support "<commit>...<commit>" */ 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); @@ -55,7 +57,7 @@ static int push_range(git_repository *repo, git_revwalk *walk, const char *range return error; } -static int revwalk_parseopts(git_repository *repo, git_revwalk *walk, int nopts, const char *const *opts) +static int revwalk_parseopts(git_repository *repo, git_revwalk *walk, int nopts, char **opts) { int hide, i, error; unsigned int sorting = GIT_SORT_NONE; |
