mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 19:51:31 +00:00
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.
This commit is contained in:
parent
7369ea8075
commit
f61272e047
@ -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
|
||||
|
@ -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;
|
||||
|
||||
commit = git_revwalk__commit_lookup(walk, oid);
|
||||
git_oid_cpy(&commit_id, git_object_id(obj));
|
||||
git_object_free(obj);
|
||||
|
||||
commit = git_revwalk__commit_lookup(walk, &commit_id);
|
||||
if (commit == NULL)
|
||||
return -1; /* error already reported by failed lookup */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user