{"thread":{"id":"39789","subject":"[PATCH v6 1/4] status: factor two rebase-related messages together","startedAt":"2015-07-06T20:56:00Z","lastAt":"2015-07-06T20:56:04Z","messageCount":5,"participants":["Matthieu Moy"],"isPatch":true,"patchVersion":6,"patchTotal":4},"messages":[{"id":"265627","messageId":"1436216164-7949-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"39789","inReplyTo":null,"subject":"[PATCH v6 0/4] status: give more information during rebase","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-07-06T20:56:00Z","receivedAt":"2015-07-06T20:56:00Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"This is almost identical to v5. I turned git_path(var) into\ngit_path(\"%s\", var) as Junio noticed, but I still prefer my version on\nthe other points discussed.\n\nGuillaume Pagès (4):\n  status: factor two rebase-related messages together\n  status: differentiate interactive from non-interactive rebases\n  status: give more information during rebase -i\n  status: add new tests for status during rebase -i\n\n t/t7512-status-help.sh | 226 ++++++++++++++++++++++++++++++++++++++++++++++---\n wt-status.c            | 151 +++++++++++++++++++++++++++++----\n 2 files changed, 346 insertions(+), 31 deletions(-)\n\n-- \n2.5.0.rc0.7.ge1edd74.dirty\n"},{"id":"265626","messageId":"1436216164-7949-2-git-send-email-Matthieu.Moy@imag.fr","threadId":"39789","inReplyTo":"1436216164-7949-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v6 1/4] status: factor two rebase-related messages together","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-07-06T20:56:01Z","receivedAt":"2015-07-06T20:56:01Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"From: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n\nSigned-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n wt-status.c | 32 ++++++++++++++++----------------\n 1 file changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex eaed4fe..8c4b806 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1027,6 +1027,20 @@ static int split_commit_in_progress(struct wt_status *s)\n \treturn split_in_progress;\n }\n \n+static void print_rebase_state(struct wt_status *s,\n+\t\t\t\tstruct wt_status_state *state,\n+\t\t\t\tconst char *color)\n+{\n+\tif (state->branch)\n+\t\tstatus_printf_ln(s, color,\n+\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t state->branch,\n+\t\t\t\t state->onto);\n+\telse\n+\t\tstatus_printf_ln(s, color,\n+\t\t\t\t _(\"You are currently rebasing.\"));\n+}\n+\n static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n@@ -1034,14 +1048,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \tstruct stat st;\n \n \tif (has_unmerged(s)) {\n-\t\tif (state->branch)\n-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n-\t\t\t\t\t state->branch,\n-\t\t\t\t\t state->onto);\n-\t\telse\n-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t\t _(\"You are currently rebasing.\"));\n+\t\tprint_rebase_state(s, state, color);\n \t\tif (s->hints) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n@@ -1051,14 +1058,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n \t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n-\t\tif (state->branch)\n-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n-\t\t\t\t\t state->branch,\n-\t\t\t\t\t state->onto);\n-\t\telse\n-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t\t _(\"You are currently rebasing.\"));\n+\t\tprint_rebase_state(s, state, color);\n \t\tif (s->hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n-- \n2.5.0.rc0.7.ge1edd74.dirty\n"},{"id":"265628","messageId":"1436216164-7949-3-git-send-email-Matthieu.Moy@imag.fr","threadId":"39789","inReplyTo":"1436216164-7949-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v6 2/4] status: differentiate interactive from non-interactive rebases","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-07-06T20:56:02Z","receivedAt":"2015-07-06T20:56:02Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"From: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n\nSigned-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t7512-status-help.sh | 28 ++++++++++++++--------------\n wt-status.c            |  5 ++++-\n 2 files changed, 18 insertions(+), 15 deletions(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 68ad2d7..190656d 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -136,7 +136,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '\n \tONTO=$(git rev-parse --short rebase_i_conflicts) &&\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n   (fix conflicts and then run \"git rebase --continue\")\n   (use \"git rebase --skip\" to skip this patch)\n@@ -162,7 +162,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tgit add main.txt &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n   (all conflicts fixed: run \"git rebase --continue\")\n \n@@ -190,7 +190,7 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \tONTO=$(git rev-parse --short HEAD~2) &&\n \tgit rebase -i HEAD~2 &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''rebase_i_edit'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -216,7 +216,7 @@ test_expect_success 'status when splitting a commit' '\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently splitting a commit while rebasing branch '\\''split_commit'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -247,7 +247,7 @@ test_expect_success 'status after editing the last commit with --amend during a\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''amend_last'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -277,7 +277,7 @@ test_expect_success 'status: (continue first edit) second edit' '\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -299,7 +299,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -326,7 +326,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '\n \tgit rebase --continue &&\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -348,7 +348,7 @@ test_expect_success 'status: (amend first edit) second edit' '\n \tgit commit --amend -m \"a\" &&\n \tgit rebase --continue &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -371,7 +371,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -399,7 +399,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tgit rebase --continue &&\n \tgit commit --amend -m \"d\" &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -423,7 +423,7 @@ test_expect_success 'status: (split first edit) second edit' '\n \tgit commit -m \"e\" &&\n \tgit rebase --continue &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -448,7 +448,7 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -478,7 +478,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tgit rebase --continue &&\n \tgit commit --amend -m \"h\" &&\n \tcat >expected <<EOF &&\n-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\ndiff --git a/wt-status.c b/wt-status.c\nindex 8c4b806..81610dc 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1328,7 +1328,10 @@ void wt_status_print(struct wt_status *s)\n \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n \t\t\tbranch_status_color = color(WT_STATUS_NOBRANCH, s);\n \t\t\tif (state.rebase_in_progress || state.rebase_interactive_in_progress) {\n-\t\t\t\ton_what = _(\"rebase in progress; onto \");\n+\t\t\t\tif (state.rebase_interactive_in_progress)\n+\t\t\t\t\ton_what = _(\"interactive rebase in progress; onto \");\n+\t\t\t\telse\n+\t\t\t\t\ton_what = _(\"rebase in progress; onto \");\n \t\t\t\tbranch_name = state.onto;\n \t\t\t} else if (state.detached_from) {\n \t\t\t\tbranch_name = state.detached_from;\n-- \n2.5.0.rc0.7.ge1edd74.dirty\n"},{"id":"265629","messageId":"1436216164-7949-4-git-send-email-Matthieu.Moy@imag.fr","threadId":"39789","inReplyTo":"1436216164-7949-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v6 3/4] status: give more information during rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-07-06T20:56:03Z","receivedAt":"2015-07-06T20:56:03Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"From: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n\ngit status gives more information during rebase -i, about the list of\ncommand that are done during the rebase. It displays the two last\ncommands executed and the two next lines to be executed. It also gives\nhints to find the whole files in .git directory.\n\nSigned-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t7512-status-help.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.c            | 114 +++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 225 insertions(+)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 190656d..9be0235 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -134,9 +134,13 @@ test_expect_success 'prepare for rebase_i_conflicts' '\n test_expect_success 'status during rebase -i when conflicts unresolved' '\n \ttest_when_finished \"git rebase --abort\" &&\n \tONTO=$(git rev-parse --short rebase_i_conflicts) &&\n+\tLAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last command done (1 command done):\n+   pick $LAST_COMMIT one_second\n+No commands remaining.\n You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n   (fix conflicts and then run \"git rebase --continue\")\n   (use \"git rebase --skip\" to skip this patch)\n@@ -159,10 +163,14 @@ test_expect_success 'status during rebase -i after resolving conflicts' '\n \tgit reset --hard rebase_i_conflicts_second &&\n \ttest_when_finished \"git rebase --abort\" &&\n \tONTO=$(git rev-parse --short rebase_i_conflicts) &&\n+\tLAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) &&\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tgit add main.txt &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last command done (1 command done):\n+   pick $LAST_COMMIT one_second\n+No commands remaining.\n You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n   (all conflicts fixed: run \"git rebase --continue\")\n \n@@ -183,7 +191,9 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \tgit checkout -b rebase_i_edit &&\n \ttest_commit one_rebase_i main.txt one &&\n \ttest_commit two_rebase_i main.txt two &&\n+\tCOMMIT2=$(git rev-parse --short rebase_i_edit) &&\n \ttest_commit three_rebase_i main.txt three &&\n+\tCOMMIT3=$(git rev-parse --short rebase_i_edit) &&\n \tFAKE_LINES=\"1 edit 2\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n@@ -191,6 +201,10 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \tgit rebase -i HEAD~2 &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   pick $COMMIT2 two_rebase_i\n+   edit $COMMIT3 three_rebase_i\n+No commands remaining.\n You are currently editing a commit while rebasing branch '\\''rebase_i_edit'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -207,8 +221,11 @@ test_expect_success 'status when splitting a commit' '\n \tgit checkout -b split_commit &&\n \ttest_commit one_split main.txt one &&\n \ttest_commit two_split main.txt two &&\n+\tCOMMIT2=$(git rev-parse --short split_commit) &&\n \ttest_commit three_split main.txt three &&\n+\tCOMMIT3=$(git rev-parse --short split_commit) &&\n \ttest_commit four_split main.txt four &&\n+\tCOMMIT4=$(git rev-parse --short split_commit) &&\n \tFAKE_LINES=\"1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n@@ -217,6 +234,12 @@ test_expect_success 'status when splitting a commit' '\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   pick $COMMIT2 two_split\n+   edit $COMMIT3 three_split\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_split\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently splitting a commit while rebasing branch '\\''split_commit'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -239,7 +262,9 @@ test_expect_success 'status after editing the last commit with --amend during a\n \ttest_commit one_amend main.txt one &&\n \ttest_commit two_amend main.txt two &&\n \ttest_commit three_amend main.txt three &&\n+\tCOMMIT3=$(git rev-parse --short amend_last) &&\n \ttest_commit four_amend main.txt four &&\n+\tCOMMIT4=$(git rev-parse --short amend_last) &&\n \tFAKE_LINES=\"1 2 edit 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n@@ -248,6 +273,11 @@ test_expect_success 'status after editing the last commit with --amend during a\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (3 commands done):\n+   pick $COMMIT3 three_amend\n+   edit $COMMIT4 four_amend\n+  (see more in file .git/rebase-merge/done)\n+No commands remaining.\n You are currently editing a commit while rebasing branch '\\''amend_last'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -273,11 +303,20 @@ test_expect_success 'status: (continue first edit) second edit' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -294,12 +333,21 @@ test_expect_success 'status: (continue first edit) second edit and split' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -321,12 +369,21 @@ test_expect_success 'status: (continue first edit) second edit and amend' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -343,12 +400,21 @@ test_expect_success 'status: (amend first edit) second edit' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"a\" &&\n \tgit rebase --continue &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -366,12 +432,21 @@ test_expect_success 'status: (amend first edit) second edit and split' '\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"b\" &&\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -393,6 +468,9 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"c\" &&\n@@ -400,6 +478,12 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tgit commit --amend -m \"d\" &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -416,6 +500,9 @@ test_expect_success 'status: (split first edit) second edit' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n@@ -424,6 +511,12 @@ test_expect_success 'status: (split first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\n@@ -440,6 +533,9 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n@@ -449,6 +545,12 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (Once your working directory is clean, run \"git rebase --continue\")\n \n@@ -470,6 +572,9 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tCOMMIT2=$(git rev-parse --short several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse --short several_edits^) &&\n+\tCOMMIT4=$(git rev-parse --short several_edits) &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n@@ -479,6 +584,12 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tgit commit --amend -m \"h\" &&\n \tcat >expected <<EOF &&\n interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command to do (1 remaining command):\n+   pick $COMMIT4 four_edits\n+  (use \"git rebase --edit-todo\" to view and edit)\n You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n   (use \"git commit --amend\" to amend the current commit)\n   (use \"git rebase --continue\" once you are satisfied with your changes)\ndiff --git a/wt-status.c b/wt-status.c\nindex 81610dc..04e01e4 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1027,6 +1027,119 @@ static int split_commit_in_progress(struct wt_status *s)\n \treturn split_in_progress;\n }\n \n+/*\n+ * Turn\n+ * \"pick d6a2f0303e897ec257dd0e0a39a5ccb709bc2047 some message\"\n+ * into\n+ * \"pick d6a2f03 some message\"\n+ *\n+ * The function assumes that the line does not contain useless spaces\n+ * before or after the command.\n+ */\n+static void abbrev_sha1_in_line(struct strbuf *line)\n+{\n+\tstruct strbuf **split;\n+\tint i;\n+\n+\tif (starts_with(line->buf, \"exec \") ||\n+\t    starts_with(line->buf, \"x \"))\n+\t\treturn;\n+\n+\tsplit = strbuf_split_max(line, ' ', 3);\n+\tif (split[0] && split[1]) {\n+\t\tunsigned char sha1[20];\n+\t\tconst char *abbrev;\n+\n+\t\t/*\n+\t\t * strbuf_split_max left a space. Trim it and re-add\n+\t\t * it after abbreviation.\n+\t\t */\n+\t\tstrbuf_trim(split[1]);\n+\t\tif (!get_sha1(split[1]->buf, sha1)) {\n+\t\t\tabbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);\n+\t\t\tstrbuf_reset(split[1]);\n+\t\t\tstrbuf_addf(split[1], \"%s \", abbrev);\n+\t\t\tstrbuf_reset(line);\n+\t\t\tfor (i = 0; split[i]; i++)\n+\t\t\t\tstrbuf_addf(line, \"%s\", split[i]->buf);\n+\t\t}\n+\t}\n+\tfor (i = 0; split[i]; i++)\n+\t\tstrbuf_release(split[i]);\n+\n+}\n+\n+static void read_rebase_todolist(const char *fname, struct string_list *lines)\n+{\n+\tstruct strbuf line = STRBUF_INIT;\n+\tFILE *f = fopen(git_path(\"%s\", fname), \"r\");\n+\n+\tif (!f)\n+\t\tdie_errno(\"Could not open file %s for reading\",\n+\t\t\t  git_path(\"%s\", fname));\n+\twhile (!strbuf_getline(&line, f, '\\n')) {\n+\t\tif (line.len && line.buf[0] == comment_line_char)\n+\t\t\tcontinue;\n+\t\tstrbuf_trim(&line);\n+\t\tif (!line.len)\n+\t\t\tcontinue;\n+\t\tabbrev_sha1_in_line(&line);\n+\t\tstring_list_append(lines, line.buf);\n+\t}\n+}\n+\n+static void show_rebase_information(struct wt_status *s,\n+\t\t\t\t\tstruct wt_status_state *state,\n+\t\t\t\t\tconst char *color)\n+{\n+\tif (state->rebase_interactive_in_progress) {\n+\t\tint i;\n+\t\tint nr_lines_to_show = 2;\n+\n+\t\tstruct string_list have_done = STRING_LIST_INIT_DUP;\n+\t\tstruct string_list yet_to_do = STRING_LIST_INIT_DUP;\n+\n+\t\tread_rebase_todolist(\"rebase-merge/done\", &have_done);\n+\t\tread_rebase_todolist(\"rebase-merge/git-rebase-todo\", &yet_to_do);\n+\n+\t\tif (have_done.nr == 0)\n+\t\t\tstatus_printf_ln(s, color, _(\"No commands done.\"));\n+\t\telse {\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\tQ_(\"Last command done (%d command done):\",\n+\t\t\t\t\t\"Last commands done (%d commands done):\",\n+\t\t\t\t\thave_done.nr),\n+\t\t\t\thave_done.nr);\n+\t\t\tfor (i = (have_done.nr > nr_lines_to_show)\n+\t\t\t\t? have_done.nr - nr_lines_to_show : 0;\n+\t\t\t\ti < have_done.nr;\n+\t\t\t\ti++)\n+\t\t\t\tstatus_printf_ln(s, color, \"   %s\", have_done.items[i].string);\n+\t\t\tif (have_done.nr > nr_lines_to_show && s->hints)\n+\t\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t_(\"  (see more in file %s)\"), git_path(\"rebase-merge/done\"));\n+\t\t}\n+\n+\t\tif (yet_to_do.nr == 0)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"No commands remaining.\"));\n+\t\telse {\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\tQ_(\"Next command to do (%d remaining command):\",\n+\t\t\t\t\t\"Next commands to do (%d remaining commands):\",\n+\t\t\t\t\tyet_to_do.nr),\n+\t\t\t\tyet_to_do.nr);\n+\t\t\tfor (i = 0; i < nr_lines_to_show && i < yet_to_do.nr; i++)\n+\t\t\t\tstatus_printf_ln(s, color, \"   %s\", yet_to_do.items[i].string);\n+\t\t\tif (s->hints)\n+\t\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t_(\"  (use \\\"git rebase --edit-todo\\\" to view and edit)\"));\n+\t\t}\n+\t\tstring_list_clear(&yet_to_do, 0);\n+\t\tstring_list_clear(&have_done, 0);\n+\t}\n+}\n+\n static void print_rebase_state(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n@@ -1047,6 +1160,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n {\n \tstruct stat st;\n \n+\tshow_rebase_information(s, state, color);\n \tif (has_unmerged(s)) {\n \t\tprint_rebase_state(s, state, color);\n \t\tif (s->hints) {\n-- \n2.5.0.rc0.7.ge1edd74.dirty\n"},{"id":"265630","messageId":"1436216164-7949-5-git-send-email-Matthieu.Moy@imag.fr","threadId":"39789","inReplyTo":"1436216164-7949-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v6 4/4] status: add new tests for status during rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-07-06T20:56:04Z","receivedAt":"2015-07-06T20:56:04Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"From: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n\nExpand test coverage with one or more than two commands done\nand with zero, one or more than two commands remaining.\n\nSigned-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t7512-status-help.sh | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 87 insertions(+)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 9be0235..49d19a3 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -856,4 +856,91 @@ EOF\n \ttest_i18ncmp expected actual\n '\n \n+test_expect_success 'prepare for different number of commits rebased' '\n+\tgit reset --hard master &&\n+\tgit checkout -b several_commits &&\n+\ttest_commit one_commit main.txt one &&\n+\ttest_commit two_commit main.txt two &&\n+\ttest_commit three_commit main.txt three &&\n+\ttest_commit four_commit main.txt four\n+'\n+\n+test_expect_success 'status: one command done nothing remaining' '\n+\tFAKE_LINES=\"exec_exit_15\" &&\n+\texport FAKE_LINES &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n+\ttest_must_fail git rebase -i HEAD~3 &&\n+\tcat >expected <<EOF &&\n+interactive rebase in progress; onto $ONTO\n+Last command done (1 command done):\n+   exec exit 15\n+No commands remaining.\n+You are currently editing a commit while rebasing branch '\\''several_commits'\\'' on '\\''$ONTO'\\''.\n+  (use \"git commit --amend\" to amend the current commit)\n+  (use \"git rebase --continue\" once you are satisfied with your changes)\n+\n+nothing to commit (use -u to show untracked files)\n+EOF\n+\tgit status --untracked-files=no >actual &&\n+\ttest_i18ncmp expected actual\n+'\n+\n+test_expect_success 'status: two commands done with some white lines in done file' '\n+\tFAKE_LINES=\"1 > exec_exit_15  2 3\" &&\n+\texport FAKE_LINES &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n+\tCOMMIT4=$(git rev-parse --short HEAD) &&\n+\tCOMMIT3=$(git rev-parse --short HEAD^) &&\n+\tCOMMIT2=$(git rev-parse --short HEAD^^) &&\n+\ttest_must_fail git rebase -i HEAD~3 &&\n+\tcat >expected <<EOF &&\n+interactive rebase in progress; onto $ONTO\n+Last commands done (2 commands done):\n+   pick $COMMIT2 two_commit\n+   exec exit 15\n+Next commands to do (2 remaining commands):\n+   pick $COMMIT3 three_commit\n+   pick $COMMIT4 four_commit\n+  (use \"git rebase --edit-todo\" to view and edit)\n+You are currently editing a commit while rebasing branch '\\''several_commits'\\'' on '\\''$ONTO'\\''.\n+  (use \"git commit --amend\" to amend the current commit)\n+  (use \"git rebase --continue\" once you are satisfied with your changes)\n+\n+nothing to commit (use -u to show untracked files)\n+EOF\n+\tgit status --untracked-files=no >actual &&\n+\ttest_i18ncmp expected actual\n+'\n+\n+test_expect_success 'status: two remaining commands with some white lines in todo file' '\n+\tFAKE_LINES=\"1 2 exec_exit_15 3 > 4\" &&\n+\texport FAKE_LINES &&\n+\ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~4) &&\n+\tCOMMIT4=$(git rev-parse --short HEAD) &&\n+\tCOMMIT3=$(git rev-parse --short HEAD^) &&\n+\tCOMMIT2=$(git rev-parse --short HEAD^^) &&\n+\ttest_must_fail git rebase -i HEAD~4 &&\n+\tcat >expected <<EOF &&\n+interactive rebase in progress; onto $ONTO\n+Last commands done (3 commands done):\n+   pick $COMMIT2 two_commit\n+   exec exit 15\n+  (see more in file .git/rebase-merge/done)\n+Next commands to do (2 remaining commands):\n+   pick $COMMIT3 three_commit\n+   pick $COMMIT4 four_commit\n+  (use \"git rebase --edit-todo\" to view and edit)\n+You are currently editing a commit while rebasing branch '\\''several_commits'\\'' on '\\''$ONTO'\\''.\n+  (use \"git commit --amend\" to amend the current commit)\n+  (use \"git rebase --continue\" once you are satisfied with your changes)\n+\n+nothing to commit (use -u to show untracked files)\n+EOF\n+\tgit status --untracked-files=no >actual &&\n+\ttest_i18ncmp expected actual\n+'\n+\n test_done\n-- \n2.5.0.rc0.7.ge1edd74.dirty\n"}]}