]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit.c
Merge branch 'tf/commit-list-prefix'
[thirdparty/git.git] / commit.c
index 554dcc3c7dccaba5fb1a671fdcab20ff16b59b1b..74d66018800d7a2a2b3a3365e87a23049690da6b 100644 (file)
--- 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)