diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-01 12:51:36 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-02-05 12:16:37 +0100 |
| commit | f61272e04727716ad09bb57e4ffa9ce4be09dc55 (patch) | |
| tree | ec760d396b940835c8023bb2bafd1cc3d201ba6c /src/revwalk.c | |
| parent | 7369ea8075fa112bbd4c13f06eeedeb2a4e47153 (diff) | |
| download | libgit2-f61272e04727716ad09bb57e4ffa9ce4be09dc55.tar.gz | |
revwalk: accept committish objects
Let the user push committish objects and peel them to figure out which
commit to push to our queue.
This is for convenience and for allowing uses of
git_revwalk_push_glob(w, "tags")
with annotated tags.
Diffstat (limited to 'src/revwalk.c')
| -rw-r--r-- | src/revwalk.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/revwalk.c b/src/revwalk.c index c0a053211..3cc3140b8 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -112,23 +112,28 @@ static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commi static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting) { + git_oid commit_id; int error; - git_object *obj; - git_otype type; + git_object *obj, *oobj; git_commit_list_node *commit; - if ((error = git_object_lookup(&obj, walk->repo, oid, GIT_OBJ_ANY)) < 0) + if ((error = git_object_lookup(&oobj, walk->repo, oid, GIT_OBJ_ANY)) < 0) return error; - type = git_object_type(obj); - git_object_free(obj); + error = git_object_peel(&obj, oobj, GIT_OBJ_COMMIT); + git_object_free(oobj); - if (type != GIT_OBJ_COMMIT) { - giterr_set(GITERR_INVALID, "Object is no commit object"); + if (error == GIT_ENOTFOUND) { + giterr_set(GITERR_INVALID, "Object is not a committish"); return -1; } + if (error < 0) + return error; + + git_oid_cpy(&commit_id, git_object_id(obj)); + git_object_free(obj); - commit = git_revwalk__commit_lookup(walk, oid); + commit = git_revwalk__commit_lookup(walk, &commit_id); if (commit == NULL) return -1; /* error already reported by failed lookup */ |
