diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh index 802f8f704c..b37e99625b 100755 --- a/t/t7512-status-help.sh +++ b/t/t7512-status-help.sh @@ -183,6 +183,81 @@ EOF test_cmp expected actual ' +test_expect_success 'status during rebase -ir after conflicted merge (exec git merge)' ' + git reset --hard main && + git checkout -b rebase_i_merge && + test_commit unrelated && + git checkout -b rebase_i_merge_side && + test_commit side2 main.txt && + git checkout rebase_i_merge && + test_commit side1 main.txt && + PICK=$(git rev-parse --short rebase_i_merge) && + test_must_fail git merge rebase_i_merge_side && + echo side1 >main.txt && + git add main.txt && + test_tick && + git commit --no-edit && + MERGE=$(git rev-parse --short rebase_i_merge) && + ONTO=$(git rev-parse --short main) && + test_when_finished "git rebase --abort" && + FAKE_LINES="1 2 3 5 6 7 8 9 10 exec_git_merge_refs/rewritten/rebase-i-merge-side" && + export FAKE_LINES && + test_must_fail git rebase -ir main && + cat >expect <..." to mark resolution) + both modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF + git status --untracked-files=no >actual && + test_cmp expect actual +' + +test_expect_success 'status during rebase -ir after replaying conflicted merge (merge)' ' + PICK=$(git rev-parse --short :/side1) && + UNRELATED=$(git rev-parse --short :/unrelated) && + MERGE=$(git rev-parse --short rebase_i_merge) && + ONTO=$(git rev-parse --short main) && + test_when_finished "git rebase --abort" && + FAKE_LINES="1 2 3 5 6 7 8 9 10 11 4" && + export FAKE_LINES && + test_must_fail git rebase -ir main && + cat >expect <..." to mark resolution) + both modified: main.txt + +no changes added to commit (use "git add" and/or "git commit -a") +EOF + git status --untracked-files=no >actual && + test_cmp expect actual +' + test_expect_success 'status when rebasing -i in edit mode' ' git reset --hard main && diff --git a/wt-status.c b/wt-status.c index d11d9f9f14..f15495039e 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1744,6 +1744,7 @@ int wt_status_check_rebase(const struct worktree *wt, struct wt_status_state *state) { struct stat st; + struct string_list have_done = STRING_LIST_INIT_DUP; if (!stat(worktree_git_path(the_repository, wt, "rebase-apply"), &st)) { if (!stat(worktree_git_path(the_repository, wt, "rebase-apply/applying"), &st)) { @@ -1760,8 +1761,12 @@ int wt_status_check_rebase(const struct worktree *wt, state->rebase_interactive_in_progress = 1; else state->rebase_in_progress = 1; + read_rebase_todolist("rebase-merge/done", &have_done); + if (have_done.nr > 0 && starts_with(have_done.items[have_done.nr - 1].string, "merge")) + state->merge_during_rebase_in_progress = 1; state->branch = get_branch(wt, "rebase-merge/head-name"); state->onto = get_branch(wt, "rebase-merge/onto"); + string_list_clear(&have_done, 0); } else return 0; return 1; @@ -1855,10 +1860,15 @@ static void wt_longstatus_print_state(struct wt_status *s) if (state->merge_in_progress) { if (state->rebase_interactive_in_progress) { - show_rebase_information(s, state_color); - fputs("\n", s->fp); - } - show_merge_in_progress(s, state_color); + if (state->merge_during_rebase_in_progress) + show_rebase_in_progress(s, state_color); + else { + show_rebase_information(s, state_color); + fputs("\n", s->fp); + show_merge_in_progress(s, state_color); + } + } else + show_merge_in_progress(s, state_color); } else if (state->am_in_progress) show_am_in_progress(s, state_color); else if (state->rebase_in_progress || state->rebase_interactive_in_progress) diff --git a/wt-status.h b/wt-status.h index 4e377ce62b..84bedfcd48 100644 --- a/wt-status.h +++ b/wt-status.h @@ -87,6 +87,7 @@ struct wt_status_state { int am_empty_patch; int rebase_in_progress; int rebase_interactive_in_progress; + int merge_during_rebase_in_progress; int cherry_pick_in_progress; int bisect_in_progress; int revert_in_progress;