Skip to content

Commit a236f90

Browse files
sivaraamgitster
authored andcommitted
branch --list: print useful info whilst interactive rebasing a detached HEAD
When rebasing interactively (rebase -i), "git branch --list" prints a line indicating the current branch being rebased. This works well when the interactive rebase is initiated when a local branch is checked out. This doesn't play well when the rebase is initiated on a detached HEAD. When "git branch --list" tries to print information related to the interactive rebase in this case it tries to print the name of a branch using an uninitialized variable and thus tries to print a "null pointer string". As a consequence, it does not provide useful information while also inducing undefined behaviour. So, print the point from which the rebase was started when interactive rebasing a detached HEAD. Signed-off-by: Kaartic Sivaraam <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit a236f90

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ref-filter.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,10 +1309,14 @@ char *get_head_description(void)
13091309
memset(&state, 0, sizeof(state));
13101310
wt_status_get_state(&state, 1);
13111311
if (state.rebase_in_progress ||
1312-
state.rebase_interactive_in_progress)
1313-
strbuf_addf(&desc, _("(no branch, rebasing %s)"),
1314-
state.branch);
1315-
else if (state.bisect_in_progress)
1312+
state.rebase_interactive_in_progress) {
1313+
if (state.branch)
1314+
strbuf_addf(&desc, _("(no branch, rebasing %s)"),
1315+
state.branch);
1316+
else
1317+
strbuf_addf(&desc, _("(no branch, rebasing detached HEAD %s)"),
1318+
state.detached_from);
1319+
} else if (state.bisect_in_progress)
13161320
strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
13171321
state.branch);
13181322
else if (state.detached_from) {

0 commit comments

Comments
 (0)