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 bisectingmaint
commit
cce4778520
4
branch.c
4
branch.c
|
@ -420,9 +420,9 @@ static void prepare_checked_out_branches(void)
|
||||||
wt_status_state_free_buffers(&state);
|
wt_status_state_free_buffers(&state);
|
||||||
|
|
||||||
if (wt_status_check_bisect(wt, &state) &&
|
if (wt_status_check_bisect(wt, &state) &&
|
||||||
state.branch) {
|
state.bisecting_from) {
|
||||||
struct strbuf ref = STRBUF_INIT;
|
struct strbuf ref = STRBUF_INIT;
|
||||||
strbuf_addf(&ref, "refs/heads/%s", state.branch);
|
strbuf_addf(&ref, "refs/heads/%s", state.bisecting_from);
|
||||||
old = strmap_put(¤t_checked_out_branches,
|
old = strmap_put(¤t_checked_out_branches,
|
||||||
ref.buf,
|
ref.buf,
|
||||||
xstrdup(wt->path));
|
xstrdup(wt->path));
|
||||||
|
|
|
@ -2212,7 +2212,7 @@ char *get_head_description(void)
|
||||||
state.detached_from);
|
state.detached_from);
|
||||||
} else if (state.bisect_in_progress)
|
} else if (state.bisect_in_progress)
|
||||||
strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
|
strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
|
||||||
state.branch);
|
state.bisecting_from);
|
||||||
else if (state.detached_from) {
|
else if (state.detached_from) {
|
||||||
if (state.detached_at)
|
if (state.detached_at)
|
||||||
strbuf_addf(&desc, _("(HEAD detached at %s)"),
|
strbuf_addf(&desc, _("(HEAD detached at %s)"),
|
||||||
|
|
|
@ -692,6 +692,34 @@ EOF
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
||||||
|
test_expect_success 'status when bisecting while rebasing' '
|
||||||
|
git reset --hard main &&
|
||||||
|
test_when_finished "git rebase --abort" &&
|
||||||
|
ONTO=$(git rev-parse --short HEAD^) &&
|
||||||
|
FAKE_LINES="break" git rebase -i HEAD^ &&
|
||||||
|
test_when_finished "git checkout -" &&
|
||||||
|
git checkout -b bisect_while_rebasing &&
|
||||||
|
test_when_finished "git bisect reset" &&
|
||||||
|
git bisect start &&
|
||||||
|
cat >expected <<EOF &&
|
||||||
|
On branch bisect_while_rebasing
|
||||||
|
Last command done (1 command done):
|
||||||
|
break
|
||||||
|
No commands remaining.
|
||||||
|
You are currently editing a commit while rebasing branch '\''bisect'\'' on '\''$ONTO'\''.
|
||||||
|
(use "git commit --amend" to amend the current commit)
|
||||||
|
(use "git rebase --continue" once you are satisfied with your changes)
|
||||||
|
|
||||||
|
You are currently bisecting, started from branch '\''bisect_while_rebasing'\''.
|
||||||
|
(use "git bisect reset" to get back to the original branch)
|
||||||
|
|
||||||
|
nothing to commit (use -u to show untracked files)
|
||||||
|
EOF
|
||||||
|
git status --untracked-files=no >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
|
||||||
test_expect_success 'status when rebase --apply conflicts with statushints disabled' '
|
test_expect_success 'status when rebase --apply conflicts with statushints disabled' '
|
||||||
git reset --hard main &&
|
git reset --hard main &&
|
||||||
git checkout -b statushints_disabled &&
|
git checkout -b statushints_disabled &&
|
||||||
|
|
|
@ -395,9 +395,9 @@ int is_worktree_being_bisected(const struct worktree *wt,
|
||||||
|
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
found_bisect = wt_status_check_bisect(wt, &state) &&
|
found_bisect = wt_status_check_bisect(wt, &state) &&
|
||||||
state.branch &&
|
state.bisecting_from &&
|
||||||
skip_prefix(target, "refs/heads/", &target) &&
|
skip_prefix(target, "refs/heads/", &target) &&
|
||||||
!strcmp(state.branch, target);
|
!strcmp(state.bisecting_from, target);
|
||||||
wt_status_state_free_buffers(&state);
|
wt_status_state_free_buffers(&state);
|
||||||
return found_bisect;
|
return found_bisect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -861,6 +861,7 @@ void wt_status_state_free_buffers(struct wt_status_state *state)
|
||||||
FREE_AND_NULL(state->branch);
|
FREE_AND_NULL(state->branch);
|
||||||
FREE_AND_NULL(state->onto);
|
FREE_AND_NULL(state->onto);
|
||||||
FREE_AND_NULL(state->detached_from);
|
FREE_AND_NULL(state->detached_from);
|
||||||
|
FREE_AND_NULL(state->bisecting_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_longstatus_print_unmerged(struct wt_status *s)
|
static void wt_longstatus_print_unmerged(struct wt_status *s)
|
||||||
|
@ -1569,10 +1570,10 @@ static void show_revert_in_progress(struct wt_status *s,
|
||||||
static void show_bisect_in_progress(struct wt_status *s,
|
static void show_bisect_in_progress(struct wt_status *s,
|
||||||
const char *color)
|
const char *color)
|
||||||
{
|
{
|
||||||
if (s->state.branch)
|
if (s->state.bisecting_from)
|
||||||
status_printf_ln(s, color,
|
status_printf_ln(s, color,
|
||||||
_("You are currently bisecting, started from branch '%s'."),
|
_("You are currently bisecting, started from branch '%s'."),
|
||||||
s->state.branch);
|
s->state.bisecting_from);
|
||||||
else
|
else
|
||||||
status_printf_ln(s, color,
|
status_printf_ln(s, color,
|
||||||
_("You are currently bisecting."));
|
_("You are currently bisecting."));
|
||||||
|
@ -1733,7 +1734,7 @@ int wt_status_check_bisect(const struct worktree *wt,
|
||||||
|
|
||||||
if (!stat(worktree_git_path(wt, "BISECT_LOG"), &st)) {
|
if (!stat(worktree_git_path(wt, "BISECT_LOG"), &st)) {
|
||||||
state->bisect_in_progress = 1;
|
state->bisect_in_progress = 1;
|
||||||
state->branch = get_branch(wt, "BISECT_START");
|
state->bisecting_from = get_branch(wt, "BISECT_START");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -94,6 +94,7 @@ struct wt_status_state {
|
||||||
char *branch;
|
char *branch;
|
||||||
char *onto;
|
char *onto;
|
||||||
char *detached_from;
|
char *detached_from;
|
||||||
|
char *bisecting_from;
|
||||||
struct object_id detached_oid;
|
struct object_id detached_oid;
|
||||||
struct object_id revert_head_oid;
|
struct object_id revert_head_oid;
|
||||||
struct object_id cherry_pick_head_oid;
|
struct object_id cherry_pick_head_oid;
|
||||||
|
|
Loading…
Reference in New Issue