Skip to content

Commit fbaf834

Browse files
author
Junio C Hamano
committed
show-branch: fix commit naming breakage.
It was ignoring the generation number of the commit when naming 2nd and later parents, showing "(linus^n)^2" for any <n> incorrectly as "linus^2". Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent c9fc748 commit fbaf834

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

show-branch.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,20 @@ static void name_commits(struct commit_list *list,
138138
nth++;
139139
if (p->object.util)
140140
continue;
141-
sprintf(newname, "%s^%d", n->head_name, nth);
141+
switch (n->generation) {
142+
case 0:
143+
sprintf(newname, "%s^%d",
144+
n->head_name, nth);
145+
break;
146+
case 1:
147+
sprintf(newname, "%s^^%d",
148+
n->head_name, nth);
149+
break;
150+
default:
151+
sprintf(newname, "%s~%d^%d",
152+
n->head_name, n->generation,
153+
nth);
154+
}
142155
name_commit(p, strdup(newname), 0);
143156
i++;
144157
name_first_parent_chain(p);

0 commit comments

Comments
 (0)