Merge branch 'maint'
[gitweb.git] / builtin-branch.c
index bd4748f845cbe8af63079d9f8a9b7222de44f9ee..77b85dde1f661069d2e07314a1d6bf80f0b27efc 100644 (file)
@@ -247,7 +247,6 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
        char c;
        int color;
        struct commit *commit;
-       char subject[256];
 
        switch (item->kind) {
        case REF_LOCAL_BRANCH:
@@ -268,17 +267,23 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
        }
 
        if (verbose) {
+               char *subject = NULL;
+               unsigned long subject_len = 0;
+               const char *sub = " **** invalid ref ****";
+
                commit = lookup_commit(item->sha1);
-               if (commit && !parse_commit(commit))
+               if (commit && !parse_commit(commit)) {
                        pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
-                                           subject, sizeof(subject), 0,
+                                           &subject, &subject_len, 0,
                                            NULL, NULL, 0);
-               else
-                       strcpy(subject, " **** invalid ref ****");
+                       sub = subject;
+               }
                printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),
                       maxwidth, item->name,
                       branch_get_color(COLOR_BRANCH_RESET),
-                      find_unique_abbrev(item->sha1, abbrev), subject);
+                      find_unique_abbrev(item->sha1, abbrev), sub);
+               if (subject)
+                       free(subject);
        } else {
                printf("%c %s%s%s\n", c, branch_get_color(color), item->name,
                       branch_get_color(COLOR_BRANCH_RESET));