X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=commit.c;h=9f4cc636dd74e99a1311500e15501bdb4875cb9d;hb=00653435488f5ed86c5d6dc411fa14fa56f5e3bc;hp=97b43279cdf46159462d5f56abc20f2161f4c7ea;hpb=8a728644263b470a6f1ac482b5c141ca61594ab8;p=git.git diff --git a/commit.c b/commit.c index 97b43279c..9f4cc636d 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);