Re: [PATCHv5 2/8] commit.c: new function for looking up a comit by name
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 13, 2010, 21:59 UTC
- Message-ID
- <7viq15iwjl.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1286478657-61581-3-git-send-email-patnotz@gmail.com>
s/comit/commit/;
"Pat Notz" <patnotz@gmail.com> writes:
Show 20 quoted lines
> diff --git a/commit.c b/commit.c
> index 0094ec1..f51098a 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -49,6 +49,19 @@ struct commit *lookup_commit(const unsigned char *sha1)
> return check_commit(obj, sha1, 0);
> }
>
> +struct commit *lookup_commit_reference_by_name(const char *name)
> +{
> + unsigned char sha1[20];
> + struct commit *commit;
> +
> + if (get_sha1(name, sha1))
> + die("could not lookup commit %s", name);
> + commit = lookup_commit_reference(sha1);
> + if (!commit || parse_commit(commit))
> + die("could not parse commit %s", name);
> + return commit;
> +}Although this wouldn't _hurt_, not very excited without seeing codepaths that can use this helper to reduce lines (there should be a lot of places, I would think). And when that happens, the helper that dies would not be very useful, as some potential callers that can benefit may want to decide what messages to issue themselves.