Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-02-01 15:51:36 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2014-02-05 15:16:37 +0400
commitf61272e04727716ad09bb57e4ffa9ce4be09dc55 (patch)
treeec760d396b940835c8023bb2bafd1cc3d201ba6c
parent7369ea8075fa112bbd4c13f06eeedeb2a4e47153 (diff)
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.
-rw-r--r--include/git2/revwalk.h8
-rw-r--r--src/revwalk.c21
2 files changed, 17 insertions, 12 deletions
diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h
index c59b79938..4eac8d43c 100644
--- a/include/git2/revwalk.h
+++ b/include/git2/revwalk.h
@@ -87,7 +87,7 @@ GIT_EXTERN(void) git_revwalk_reset(git_revwalk *walker);
/**
* Mark a commit to start traversal from.
*
- * The given OID must belong to a commit on the walked
+ * The given OID must belong to a committish on the walked
* repository.
*
* The given commit will be used as one of the roots
@@ -127,7 +127,7 @@ GIT_EXTERN(int) git_revwalk_push_head(git_revwalk *walk);
/**
* Mark a commit (and its ancestors) uninteresting for the output.
*
- * The given OID must belong to a commit on the walked
+ * The given OID must belong to a committish on the walked
* repository.
*
* The resolved commit and all its parents will be hidden from the
@@ -166,7 +166,7 @@ GIT_EXTERN(int) git_revwalk_hide_head(git_revwalk *walk);
/**
* Push the OID pointed to by a reference
*
- * The reference must point to a commit.
+ * The reference must point to a committish.
*
* @param walk the walker being used for the traversal
* @param refname the reference to push
@@ -177,7 +177,7 @@ GIT_EXTERN(int) git_revwalk_push_ref(git_revwalk *walk, const char *refname);
/**
* Hide the OID pointed to by a reference
*
- * The reference must point to a commit.
+ * The reference must point to a committish.
*
* @param walk the walker being used for the traversal
* @param refname the reference to hide
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 */