From: Guillaume Pagès Date: Tue, 09 Jun 2015 14:42:41 GMT Subject: [PATCH 3/4] status: give more information during rebase -i Message-ID: <1433860962-13222-3-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr> In-Reply-To: <1433860962-13222-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr> git status gives more information during rebase -i, about the list of command that are done during the rebase. It displays the two last commands executed and the two next lines to be executed. It also gives hints to find the whole files in .git directory. Signed-off-by: Guillaume Pagès --- t/t7512-status-help.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ wt-status.c | 64 ++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh index 190656d..0c889fa 100755 --- a/t/t7512-status-help.sh +++ b/t/t7512-status-help.sh @@ -134,9 +134,13 @@ test_expect_success 'prepare for rebase_i_conflicts' ' test_expect_success 'status during rebase -i when conflicts unresolved' ' test_when_finished "git rebase --abort" && ONTO=$(git rev-parse --short rebase_i_conflicts) && + LAST_COMMIT=$(git rev-parse rebase_i_conflicts_second) && test_must_fail git rebase -i rebase_i_conflicts && cat >expected <expected <expected <expected <expected <expected <expected <expected <expected <expected <expected <expected <expected <expected <rebase_interactive_in_progress) { + int i; + int nr_lines_to_show = 2; + + struct strbuf buf = STRBUF_INIT; + struct string_list have_done = STRING_LIST_INIT_DUP; + struct string_list yet_to_do = STRING_LIST_INIT_DUP; + + strbuf_read_file(&buf, git_path("rebase-merge/done"), 0); + stripspace(&buf, 1); + string_list_split(&have_done, buf.buf, '\n', -1); + string_list_remove_empty_items(&have_done, 1); + strbuf_release(&buf); + + strbuf_read_file(&buf, git_path("rebase-merge/git-rebase-todo"), 0); + stripspace(&buf, 1); + string_list_split(&yet_to_do, buf.buf, '\n', -1); + string_list_remove_empty_items(&yet_to_do, 1); + strbuf_release(&buf); + + if (have_done.nr == 0) + status_printf_ln(s, color, _("No commands done.")); + else { + status_printf_ln(s, color, + Q_("Last command done (%d command done):", + "Last commands done (%d commands done):", + have_done.nr), + have_done.nr); + for (i = (have_done.nr > nr_lines_to_show) + ? have_done.nr - nr_lines_to_show : 0; + i < have_done.nr; + i++) + status_printf_ln(s, color, " %s", have_done.items[i].string); + if (have_done.nr > nr_lines_to_show && s->hints) + status_printf_ln(s, color, + _(" (see more in file %s)"), git_path("rebase-merge/done")); + } + + if (yet_to_do.nr == 0) + status_printf_ln(s, color, + _("No commands remaining.")); + else { + status_printf_ln(s, color, + Q_("Next command to do (%d remaining command):", + "Next commands to do (%d remaining commands):", + yet_to_do.nr), + yet_to_do.nr); + for (i = 0; i < nr_lines_to_show && i < yet_to_do.nr; i++) + status_printf_ln(s, color, " %s", yet_to_do.items[i].string); + if (s->hints) + status_printf_ln(s, color, + _(" (use \"git rebase --edit-todo\" to view and edit)")); + } + string_list_clear(&yet_to_do, 0); + string_list_clear(&have_done, 0); + } +} + static void print_rebase_state(struct wt_status *s, struct wt_status_state *state, const char *color) @@ -1045,6 +1108,7 @@ static void show_rebase_in_progress(struct wt_status *s, { struct stat st; + show_rebase_information(s, state, color); if (has_unmerged(s)) { print_rebase_state(s, state, color); if (s->hints) { -- 2.4.2.342.ga3499d3