diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-22 22:26:57 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-22 22:26:57 +0400 |
commit | 4fe3ed130201a95212dd18cb3bef104d44ed49c4 (patch) | |
tree | 656323f2bce2c65548777ea7ac3796f5b50203f5 | |
parent | 63a4d8d7236e03c8a8f30c2da83a84a8fe8dfe66 (diff) | |
parent | aaa07e3eee6f42d0adeac826dfb52d5ade26defc (diff) |
Merge branch 'jk/show-branch-strbuf' into maint
* 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); } |