Merge branch 'jk/show-branch-strbuf' into maint

* jk/show-branch-strbuf:
  show-branch: use strbuf instead of static buffer
maint
Junio C Hamano 2013-04-22 11:26:57 -07:00
commit 4fe3ed1302
1 changed files with 8 additions and 9 deletions

View File

@ -162,29 +162,28 @@ static void name_commits(struct commit_list *list,
nth = 0; nth = 0;
while (parents) { while (parents) {
struct commit *p = parents->item; struct commit *p = parents->item;
char newname[1000], *en; struct strbuf newname = STRBUF_INIT;
parents = parents->next; parents = parents->next;
nth++; nth++;
if (p->util) if (p->util)
continue; continue;
en = newname;
switch (n->generation) { switch (n->generation) {
case 0: case 0:
en += sprintf(en, "%s", n->head_name); strbuf_addstr(&newname, n->head_name);
break; break;
case 1: case 1:
en += sprintf(en, "%s^", n->head_name); strbuf_addf(&newname, "%s^", n->head_name);
break; break;
default: default:
en += sprintf(en, "%s~%d", strbuf_addf(&newname, "%s~%d",
n->head_name, n->generation); n->head_name, n->generation);
break; break;
} }
if (nth == 1) if (nth == 1)
en += sprintf(en, "^"); strbuf_addch(&newname, '^');
else else
en += sprintf(en, "^%d", nth); strbuf_addf(&newname, "^%d", nth);
name_commit(p, xstrdup(newname), 0); name_commit(p, strbuf_detach(&newname, NULL), 0);
i++; i++;
name_first_parent_chain(p); name_first_parent_chain(p);
} }