X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=commit.c;h=b21335ee4c775d82901fb6b7dc785d63244f2bdd;hb=a5066a0b07deb76327e3e3ea845afc899e256c51;hp=0094ec1c9278332f736d2814c847b272788a7dd3;hpb=f5a5531e4e08c22ff1c3f02c43954896b947b158;p=git.git diff --git a/commit.c b/commit.c index 0094ec1c9..b21335ee4 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)) + 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; @@ -137,12 +150,8 @@ struct commit_graft *read_graft_line(char *buf, int len) buf[--len] = '\0'; if (buf[0] == '#' || buf[0] == '\0') return NULL; - if ((len + 1) % 41) { - bad_graft_data: - error("bad graft data: %s", buf); - free(graft); - return NULL; - } + if ((len + 1) % 41) + goto bad_graft_data; i = (len + 1) / 41 - 1; graft = xmalloc(sizeof(*graft) + 20 * i); graft->nr_parent = i; @@ -155,6 +164,11 @@ struct commit_graft *read_graft_line(char *buf, int len) goto bad_graft_data; } return graft; + +bad_graft_data: + error("bad graft data: %s", buf); + free(graft); + return NULL; } static int read_graft_file(const char *graft_file)