X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-show-branch.c;h=07a0c2316bec4dd8341ea494b02874a1b12483cd;hb=44c637c8021e44253f0f8cb17391092e08b39e73;hp=c892f1f7a643b3d7e5c298837424a72cbc2c4f78;hpb=5f5dbd719d0d8ec136f32a0a56674902bd85f72f;p=git.git diff --git a/builtin-show-branch.c b/builtin-show-branch.c index c892f1f7a..07a0c2316 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -259,17 +259,18 @@ static void join_revs(struct commit_list **list_p, static void show_one_commit(struct commit *commit, int no_name) { - char pretty[256], *cp; + struct strbuf pretty; + const char *pretty_str = "(unavailable)"; struct commit_name *name = commit->util; - if (commit->object.parsed) - pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - pretty, sizeof(pretty), 0, NULL, NULL, 0); - else - strcpy(pretty, "(unavailable)"); - if (!prefixcmp(pretty, "[PATCH] ")) - cp = pretty + 8; - else - cp = pretty; + + strbuf_init(&pretty, 0); + if (commit->object.parsed) { + pretty_print_commit(CMIT_FMT_ONELINE, commit, + &pretty, 0, NULL, NULL, 0); + pretty_str = pretty.buf; + } + if (!prefixcmp(pretty_str, "[PATCH] ")) + pretty_str += 8; if (!no_name) { if (name && name->head_name) { @@ -286,7 +287,8 @@ static void show_one_commit(struct commit *commit, int no_name) printf("[%s] ", find_unique_abbrev(commit->object.sha1, 7)); } - puts(cp); + puts(pretty_str); + strbuf_release(&pretty); } static char *ref_name[MAX_REVS + 1];