X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=commit.c;h=73b7e00292ba2de33fa43b5f028fd807a460af34;hb=b13e3eacefc0fb6f4f89738f74ba5ef14437bed5;hp=97b43279cdf46159462d5f56abc20f2161f4c7ea;hpb=e63f87a6f7a4e55f50e67b112f26d9a1e4e7f3ab;p=git.git diff --git a/commit.c b/commit.c index 97b43279c..73b7e0029 100644 --- a/commit.c +++ b/commit.c @@ -39,6 +39,18 @@ struct commit *lookup_commit_reference(const unsigned char *sha1) return lookup_commit_reference_gently(sha1, 0); } +struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name) +{ + struct commit *c = lookup_commit_reference(sha1); + if (!c) + die(_("could not parse %s"), ref_name); + if (hashcmp(sha1, c->object.sha1)) { + warning(_("%s %s is not a commit!"), + ref_name, sha1_to_hex(sha1)); + } + return c; +} + struct commit *lookup_commit(const unsigned char *sha1) { struct object *obj = lookup_object(sha1); @@ -430,6 +442,20 @@ void clear_commit_marks(struct commit *commit, unsigned int mark) } } +void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark) +{ + struct object *object; + struct commit *commit; + unsigned int i; + + for (i = 0; i < a->nr; i++) { + object = a->objects[i].item; + commit = lookup_commit_reference_gently(object->sha1, 1); + if (commit) + clear_commit_marks(commit, mark); + } +} + struct commit *pop_commit(struct commit_list **stack) { struct commit_list *top = *stack;