diff options
author | Pat Notz <patnotz@gmail.com> | 2010-11-02 13:59:07 -0600 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-11-04 13:53:34 -0700 |
commit | a6fa59924d154f2dcfc331357bf553e043aa0242 (patch) | |
tree | 0b70643b0e0a30f6d97acce2a9142af0a80fcde7 /commit.c | |
parent | c752e7f3e8d96a9673ad248addc9418164bd3ce6 (diff) | |
download | git-a6fa59924d154f2dcfc331357bf553e043aa0242.tar.gz |
commit: helper methods to reduce redundant blocks of code
* builtin/commit.c: Replace block of code with a one-liner call to
logmsg_reencode().
* commit.c: new function for looking up a comit by name
* pretty.c: helper methods for getting output encodings
Add helpers get_log_output_encoding() and
get_commit_output_encoding() that eliminate some messy and duplicate
if-blocks.
Signed-off-by: Pat Notz <patnotz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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)) + return NULL; + commit = lookup_commit_reference(sha1); + if (!commit || parse_commit(commit)) + return NULL; + return commit; +} + static unsigned long parse_commit_date(const char *buf, const char *tail) { const char *dateptr; |