Skip to content

Commit cce4778

Browse files
committed
Merge branch 'rj/status-bisect-while-rebase'
"git status" is taught to show both the branch being bisected and being rebased when both are in effect at the same time. * rj/status-bisect-while-rebase: status: fix branch shown when not only bisecting
2 parents 59a29e1 + 990adcc commit cce4778

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

branch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,9 @@ static void prepare_checked_out_branches(void)
420420
wt_status_state_free_buffers(&state);
421421

422422
if (wt_status_check_bisect(wt, &state) &&
423-
state.branch) {
423+
state.bisecting_from) {
424424
struct strbuf ref = STRBUF_INIT;
425-
strbuf_addf(&ref, "refs/heads/%s", state.branch);
425+
strbuf_addf(&ref, "refs/heads/%s", state.bisecting_from);
426426
old = strmap_put(&current_checked_out_branches,
427427
ref.buf,
428428
xstrdup(wt->path));

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,7 @@ char *get_head_description(void)
22122212
state.detached_from);
22132213
} else if (state.bisect_in_progress)
22142214
strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
2215-
state.branch);
2215+
state.bisecting_from);
22162216
else if (state.detached_from) {
22172217
if (state.detached_at)
22182218
strbuf_addf(&desc, _("(HEAD detached at %s)"),

t/t7512-status-help.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,34 @@ EOF
692692
'
693693

694694

695+
test_expect_success 'status when bisecting while rebasing' '
696+
git reset --hard main &&
697+
test_when_finished "git rebase --abort" &&
698+
ONTO=$(git rev-parse --short HEAD^) &&
699+
FAKE_LINES="break" git rebase -i HEAD^ &&
700+
test_when_finished "git checkout -" &&
701+
git checkout -b bisect_while_rebasing &&
702+
test_when_finished "git bisect reset" &&
703+
git bisect start &&
704+
cat >expected <<EOF &&
705+
On branch bisect_while_rebasing
706+
Last command done (1 command done):
707+
break
708+
No commands remaining.
709+
You are currently editing a commit while rebasing branch '\''bisect'\'' on '\''$ONTO'\''.
710+
(use "git commit --amend" to amend the current commit)
711+
(use "git rebase --continue" once you are satisfied with your changes)
712+
713+
You are currently bisecting, started from branch '\''bisect_while_rebasing'\''.
714+
(use "git bisect reset" to get back to the original branch)
715+
716+
nothing to commit (use -u to show untracked files)
717+
EOF
718+
git status --untracked-files=no >actual &&
719+
test_cmp expected actual
720+
'
721+
722+
695723
test_expect_success 'status when rebase --apply conflicts with statushints disabled' '
696724
git reset --hard main &&
697725
git checkout -b statushints_disabled &&

worktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ int is_worktree_being_bisected(const struct worktree *wt,
395395

396396
memset(&state, 0, sizeof(state));
397397
found_bisect = wt_status_check_bisect(wt, &state) &&
398-
state.branch &&
398+
state.bisecting_from &&
399399
skip_prefix(target, "refs/heads/", &target) &&
400-
!strcmp(state.branch, target);
400+
!strcmp(state.bisecting_from, target);
401401
wt_status_state_free_buffers(&state);
402402
return found_bisect;
403403
}

wt-status.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ void wt_status_state_free_buffers(struct wt_status_state *state)
861861
FREE_AND_NULL(state->branch);
862862
FREE_AND_NULL(state->onto);
863863
FREE_AND_NULL(state->detached_from);
864+
FREE_AND_NULL(state->bisecting_from);
864865
}
865866

866867
static void wt_longstatus_print_unmerged(struct wt_status *s)
@@ -1569,10 +1570,10 @@ static void show_revert_in_progress(struct wt_status *s,
15691570
static void show_bisect_in_progress(struct wt_status *s,
15701571
const char *color)
15711572
{
1572-
if (s->state.branch)
1573+
if (s->state.bisecting_from)
15731574
status_printf_ln(s, color,
15741575
_("You are currently bisecting, started from branch '%s'."),
1575-
s->state.branch);
1576+
s->state.bisecting_from);
15761577
else
15771578
status_printf_ln(s, color,
15781579
_("You are currently bisecting."));
@@ -1733,7 +1734,7 @@ int wt_status_check_bisect(const struct worktree *wt,
17331734

17341735
if (!stat(worktree_git_path(wt, "BISECT_LOG"), &st)) {
17351736
state->bisect_in_progress = 1;
1736-
state->branch = get_branch(wt, "BISECT_START");
1737+
state->bisecting_from = get_branch(wt, "BISECT_START");
17371738
return 1;
17381739
}
17391740
return 0;

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct wt_status_state {
9494
char *branch;
9595
char *onto;
9696
char *detached_from;
97+
char *bisecting_from;
9798
struct object_id detached_oid;
9899
struct object_id revert_head_oid;
99100
struct object_id cherry_pick_head_oid;

0 commit comments

Comments
 (0)