Skip to content

Commit

Permalink
Merge branch 'jk/show-branch-strbuf' into maint
Browse files Browse the repository at this point in the history
* jk/show-branch-strbuf:
  show-branch: use strbuf instead of static buffer
  • Loading branch information
Junio C Hamano committed Apr 22, 2013
2 parents 63a4d8d + aaa07e3 commit 4fe3ed1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions builtin/show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 4fe3ed1

Please sign in to comment.