diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-15 12:40:49 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-15 12:40:49 -0700 |
commit | 51ff04baad8f989727b7ce3c2679fac4f903e602 (patch) | |
tree | 87b19f3cad6f20636b7e156cfa3ae6888d405efe | |
parent | Merge branch 'jk/http-error-messages' (diff) | |
parent | show-branch: use strbuf instead of static buffer (diff) | |
download | tgif-51ff04baad8f989727b7ce3c2679fac4f903e602.tar.xz |
Merge branch 'jk/show-branch-strbuf'
"git show-branch" was not prepared to show a very long run of
ancestor operators e.g. foobar^2~2^2^2^2...^2~4 correctly.
* jk/show-branch-strbuf:
show-branch: use strbuf instead of static buffer
-rw-r--r-- | builtin/show-branch.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c index d208fd6c68..90fc6b1b9d 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -162,29 +162,28 @@ static void name_commits(struct commit_list *list, nth = 0; while (parents) { struct commit *p = parents->item; - char newname[1000], *en; + struct strbuf newname = STRBUF_INIT; parents = parents->next; nth++; if (p->util) continue; - en = newname; switch (n->generation) { case 0: - en += sprintf(en, "%s", n->head_name); + strbuf_addstr(&newname, n->head_name); break; case 1: - en += sprintf(en, "%s^", n->head_name); + strbuf_addf(&newname, "%s^", n->head_name); break; default: - en += sprintf(en, "%s~%d", - n->head_name, n->generation); + strbuf_addf(&newname, "%s~%d", + n->head_name, n->generation); break; } if (nth == 1) - en += sprintf(en, "^"); + strbuf_addch(&newname, '^'); else - en += sprintf(en, "^%d", nth); - name_commit(p, xstrdup(newname), 0); + strbuf_addf(&newname, "^%d", nth); + name_commit(p, strbuf_detach(&newname, NULL), 0); i++; name_first_parent_chain(p); } |