{"thread":{"id":"39561","subject":"[PATCH 3/4] status: give more information during rebase -i","startedAt":"2015-06-08T14:55:07Z","lastAt":"2015-06-09T08:57:38Z","messageCount":5,"participants":["Guillaume Pagès","Matthieu Moy","Junio C Hamano","Guillaume Pages"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"263216","messageId":"1433775308-5451-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39561","inReplyTo":null,"subject":"[PATCH 3/4] status: give more information during rebase -i","fromName":"Guillaume Pagès","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-08T14:55:07Z","receivedAt":"2015-06-08T14:55:07Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"git 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---\n\nI've applied your remarks, the way to read into file has been changed\nand the \" has been added. I haven't been able to configure clang-format\nso I checked many times the coding style, and hope there is no more mistakes.\n\n t/t7512-status-help.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.c            |  61 +++++++++++++++++++++++++++\n 2 files changed, 172 insertions(+)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 190656d..0c889fa 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 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 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 rebase_i_edit) &&\n \ttest_commit three_rebase_i main.txt three &&\n+\tCOMMIT3=$(git rev-parse 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 split_commit) &&\n \ttest_commit three_split main.txt three &&\n+\tCOMMIT3=$(git rev-parse split_commit) &&\n \ttest_commit four_split main.txt four &&\n+\tCOMMIT4=$(git rev-parse 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 amend_last) &&\n \ttest_commit four_amend main.txt four &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 several_edits^^) &&\n+\tCOMMIT3=$(git rev-parse several_edits^) &&\n+\tCOMMIT4=$(git rev-parse 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 c83eca5..7f88470 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1026,12 +1026,73 @@ static int split_commit_in_progress(struct wt_status *s)\n \treturn split_in_progress;\n }\n \n+static void show_rebase_information(struct wt_status *s,\n+\t\t\t\t    struct wt_status_state *state,\n+\t\t\t\t    const char *color)\n+{\n+\tif (state->rebase_interactive_in_progress) {\n+\t\tint i, begin;\n+\t\tint lines_to_show_nr = 2;\n+\n+\t\tstruct strbuf buf = STRBUF_INIT;\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\tstrbuf_read_file(&buf, git_path(\"rebase-merge/done\"), 0);\n+\t\tstripspace(&buf, 1);\n+\t\thave_done.nr = string_list_split(&have_done, buf.buf, '\\n', -1);\n+\t\tstring_list_remove_empty_items(&have_done, 1);\n+\t\tstrbuf_release(&buf);\n+\n+\t\tstrbuf_read_file(&buf, git_path(\"rebase-merge/git-rebase-todo\"), 0);\n+\t\tstripspace(&buf, 1);\n+\t\tstring_list_split(&yet_to_do, buf.buf, '\\n', -1);\n+\t\tstring_list_remove_empty_items(&yet_to_do, 1);\n+\t\tstrbuf_release(&buf);\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\tbegin = (have_done.nr > lines_to_show_nr) ? have_done.nr-lines_to_show_nr : 0;\n+\t\t\tfor (i = begin; i < have_done.nr; i++) {\n+\t\t\t\tstatus_printf_ln(s, color, \"   %s\", have_done.items[i].string);\n+\t\t\t}\n+\t\t\tif (have_done.nr > lines_to_show_nr && s->hints)\n+\t\t\t   status_printf_ln(s, color,\n+\t\t\t\t_(\"  (see more in file %s)\"), git_path(\"rebase-merge/done\"));\n+\t\t}\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+\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 < lines_to_show_nr && 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\t}\n+\t\t\tif (s->hints)\n+\t\t\t   status_printf_ln(s, color,\n+\t\t\t\t_(\"  (use \\\"git rebase --edit-todo\\\" to view and edit)\"));\n+\t\t}\n+\t}\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 {\n \tstruct stat st;\n \n+\tshow_rebase_information(s, state, color);\n \tif (has_unmerged(s) || state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n \t\tif (state->branch)\n \t\t\tstatus_printf_ln(s, color,\n-- \n2.4.2.342.gc0899ef\n"},{"id":"263217","messageId":"1433775308-5451-2-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39561","inReplyTo":"1433775308-5451-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"[PATCH 4/4] status: add new tests for status during rebase -i","fromName":"Guillaume Pagès","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-08T14:55:08Z","receivedAt":"2015-06-08T14:55:08Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"Expand test coverage with one or more than two commands done\nand with zero, one or more than two commands remaining\n---\n t/t7512-status-help.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 88 insertions(+)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 0c889fa..844ba15 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -856,4 +856,92 @@ 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+\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+\t(git rebase -i HEAD~3 || true) &&\n+       cat >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 HEAD) &&\n+\tCOMMIT3=$(git rev-parse HEAD^) &&\n+\tCOMMIT2=$(git rev-parse HEAD^^) &&\n+\t(git rebase -i HEAD~3 || true) &&\n+       cat >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 HEAD) &&\n+\tCOMMIT3=$(git rev-parse HEAD^) &&\n+\tCOMMIT2=$(git rev-parse HEAD^^) &&\n+\t(git rebase -i HEAD~4 || true) &&\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.4.2.342.gc0899ef\n"},{"id":"263242","messageId":"vpqeglm41jm.fsf@anie.imag.fr","threadId":"39561","inReplyTo":"1433775308-5451-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [PATCH 3/4] status: give more information during rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-08T16:17:49Z","receivedAt":"2015-06-08T16:17:49Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Please, include a version number in the subject. git send-email -v2 does\nthis for you.\n\nGuillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> +static void show_rebase_information(struct wt_status *s,\n> +\t\t\t\t    struct wt_status_state *state,\n> +\t\t\t\t    const char *color)\n> +{\n> +\tif (state->rebase_interactive_in_progress) {\n> +\t\tint i, begin;\n> +\t\tint lines_to_show_nr = 2;\n> +\n> +\t\tstruct strbuf buf = STRBUF_INIT;\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\tstrbuf_read_file(&buf, git_path(\"rebase-merge/done\"), 0);\n> +\t\tstripspace(&buf, 1);\n> +\t\thave_done.nr = string_list_split(&have_done, buf.buf, '\\n', -1);\n> +\t\tstring_list_remove_empty_items(&have_done, 1);\n> +\t\tstrbuf_release(&buf);\n\nI'd release buf one line earlier (meaning \"I'm done with buf, now let's\ntalk about something else\"), but it's OK like this too\n\n> +\t\tstrbuf_read_file(&buf, git_path(\"rebase-merge/git-rebase-todo\"), 0);\n> +\t\tstripspace(&buf, 1);\n> +\t\tstring_list_split(&yet_to_do, buf.buf, '\\n', -1);\n> +\t\tstring_list_remove_empty_items(&yet_to_do, 1);\n> +\t\tstrbuf_release(&buf);\n\nNice. Much simpler than the previous iteration.\n\n> +\t\tif (have_done.nr == 0)\n> +\t\t\tstatus_printf_ln(s, color, _(\"No commands done.\"));\n> +\t\telse{\n\nMissing space before {\n\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\tbegin = (have_done.nr > lines_to_show_nr) ? have_done.nr-lines_to_show_nr : 0;\n\nMissing space around '-'\n\n> +\t\t\tfor (i = begin; i < have_done.nr; i++) {\n> +\t\t\t\tstatus_printf_ln(s, color, \"   %s\", have_done.items[i].string);\n> +\t\t\t}\n\nUseless braces.\n\n> +\t\t\tif (have_done.nr > lines_to_show_nr && s->hints)\n> +\t\t\t   status_printf_ln(s, color,\n\nIndentation with space (open in Emacs, M-x whitespace-mode RET to see\nthis kind of things).\n\n> +\t\t\t\t_(\"  (see more in file %s)\"), git_path(\"rebase-merge/done\"));\n> +\t\t}\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> +\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 < lines_to_show_nr && 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\t}\n\nUseless braces.\n\n> +\t\t\tif (s->hints)\n> +\t\t\t   status_printf_ln(s, color,\n\nIndentation with space again.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"263316","messageId":"xmqq7frd97g7.fsf@gitster.dls.corp.google.com","threadId":"39561","inReplyTo":"1433775308-5451-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [PATCH 3/4] status: give more information during rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-08T22:11:20Z","receivedAt":"2015-06-08T22:11:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Guillaume Pagès  <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> git status gives more information during rebase -i, about the list of\n> command that are done during the rebase. It displays the two last\n> commands executed and the two next lines to be executed. It also gives\n> hints to find the whole files in .git directory.\n> ---\n\nWithout 1/4 and 2/4 in the same thread, it is hard to guess what you\nwanted to do with these two patches.  Remember, reviewers review not\njust your patches but those from many others.\n\nI would in the meantime assume these are replacement patches for the\nones in\n\n  http://thread.gmane.org/gmane.comp.version-control.git/270743/focus=270744\n\n> diff --git a/wt-status.c b/wt-status.c\n> index c83eca5..7f88470 100644\n> --- a/wt-status.c\n> +++ b/wt-status.c\n> @@ -1026,12 +1026,73 @@ static int split_commit_in_progress(struct wt_status *s)\n>  \treturn split_in_progress;\n>  }\n>  \n> +static void show_rebase_information(struct wt_status *s,\n> +\t\t\t\t    struct wt_status_state *state,\n> +\t\t\t\t    const char *color)\n> +{\n> +\tif (state->rebase_interactive_in_progress) {\n> +\t\tint i, begin;\n> +\t\tint lines_to_show_nr = 2;\n\n\"lines_to_show = 2\" or \"nr_lines_to_show = 2\" would be easier to read.\n\n> +\n> +\t\tstruct strbuf buf = STRBUF_INIT;\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\tstrbuf_read_file(&buf, git_path(\"rebase-merge/done\"), 0);\n> +\t\tstripspace(&buf, 1);\n> +\t\thave_done.nr = string_list_split(&have_done, buf.buf, '\\n', -1);\n> +\t\tstring_list_remove_empty_items(&have_done, 1);\n> +\t\tstrbuf_release(&buf);\n> +\n> +\t\tstrbuf_read_file(&buf, git_path(\"rebase-merge/git-rebase-todo\"), 0);\n> +\t\tstripspace(&buf, 1);\n> +\t\tstring_list_split(&yet_to_do, buf.buf, '\\n', -1);\n> +\t\tstring_list_remove_empty_items(&yet_to_do, 1);\n> +\t\tstrbuf_release(&buf);\n> +\n> +\t\tif (have_done.nr == 0)\n> +\t\t\tstatus_printf_ln(s, color, _(\"No commands done.\"));\n\nDo the users even need to be told that, I wonder?\n\n> +\t\telse{\n\nStyle:\t\"else {\"\n\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\tbegin = (have_done.nr > lines_to_show_nr) ? have_done.nr-lines_to_show_nr : 0;\n> +\t\t\tfor (i = begin; i < have_done.nr; i++) {\n> +\t\t\t\tstatus_printf_ln(s, color, \"   %s\", have_done.items[i].string);\n> +\t\t\t}\n\nHmm, perhaps fold lines like this (and you do not need \"begin\")?\n\n\t\t\tfor (i = (lines_to_show_nr < have_done.nr)\n                             ? have_done.nr - lines_to_show_nr : 0;\n                             i < have_done.nr;\n                             i++)\n\t\t\t\tstatus_printf_ln(...);\n\n> +\t\t\tif (have_done.nr > lines_to_show_nr && s->hints)\n> +\t\t\t   status_printf_ln(s, color,\n> +\t\t\t\t_(\"  (see more in file %s)\"), git_path(\"rebase-merge/done\"));\n\nThat's a nice touch ;-)\n\n> +\t\t}\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\nThis I can see why we may want to say it.\n\n> +\t\telse{\n> +\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 < lines_to_show_nr && 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\t}\n> +\t\t\tif (s->hints)\n> +\t\t\t   status_printf_ln(s, color,\n> +\t\t\t\t_(\"  (use \\\"git rebase --edit-todo\\\" to view and edit)\"));\n> +\t\t}\n\nMake sure you do not leak memory used by two string lists here...\n\n> +\t}\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>  {\n>  \tstruct stat st;\n>  \n> +\tshow_rebase_information(s, state, color);\n>  \tif (has_unmerged(s) || state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n>  \t\tif (state->branch)\n>  \t\t\tstatus_printf_ln(s, color,\n"},{"id":"263332","messageId":"1393139524.297448.1433840258348.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39561","inReplyTo":"xmqq7frd97g7.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 3/4] status: give more information during rebase -i","fromName":"Guillaume Pages","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-09T08:57:38Z","receivedAt":"2015-06-09T08:57:38Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"\"Junio C Hamano\" <gitster@pobox.com> writes:\n\n>Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes: \n\n>> git status gives more information during rebase -i, about the list of \n>> command that are done during the rebase. It displays the two last \n>> commands executed and the two next lines to be executed. It also gives \n>> hints to find the whole files in .git directory. \n>> --- \n\n>Without 1/4 and 2/4 in the same thread, it is hard to guess what you \n>wanted to do with these two patches. Remember, reviewers review not \n>just your patches but those from many others. \n\n>I would in the meantime assume these are replacement patches for the \n>ones in \n\n>http://thread.gmane.org/gmane.comp.version-control.git/270743/focus=270744 \n\nYou assumed correctly, I didn't wanted to flood the mailing list and I\nassumed it would be linked correctly with the previous since. Looks like\nI was wrong.\n\n>> diff --git a/wt-status.c b/wt-status.c \n>> index c83eca5..7f88470 100644 \n>> --- a/wt-status.c \n>> +++ b/wt-status.c \n>> @@ -1026,12 +1026,73 @@ static int split_commit_in_progress(struct wt_status *s) \n>> return split_in_progress; \n>> } \n>> \n>> +static void show_rebase_information(struct wt_status *s, \n>> + struct wt_status_state *state, \n>> + const char *color) \n>> +{ \n>> + if (state->rebase_interactive_in_progress) { \n>> + int i, begin; \n>> + int lines_to_show_nr = 2; \n\n>\"lines_to_show = 2\" or \"nr_lines_to_show = 2\" would be easier to read. \n\nDone\n\n>> + \n>> + struct strbuf buf = STRBUF_INIT; \n>> + struct string_list have_done = STRING_LIST_INIT_DUP; \n>> + struct string_list yet_to_do = STRING_LIST_INIT_DUP; \n>> + \n>> + strbuf_read_file(&buf, git_path(\"rebase-merge/done\"), 0); \n>> + stripspace(&buf, 1); \n>> + have_done.nr = string_list_split(&have_done, buf.buf, '\\n', -1); \n>> + string_list_remove_empty_items(&have_done, 1); \n>> + strbuf_release(&buf); \n>> + \n>> + strbuf_read_file(&buf, git_path(\"rebase-merge/git-rebase-todo\"), 0); \n>> + stripspace(&buf, 1); \n>> + string_list_split(&yet_to_do, buf.buf, '\\n', -1); \n>> + string_list_remove_empty_items(&yet_to_do, 1); \n>> + strbuf_release(&buf); \n>> + \n>> + if (have_done.nr == 0) \n>> + status_printf_ln(s, color, _(\"No commands done.\")); \n\n>Do the users even need to be told that, I wonder? \n\nI guess it removes the ambiguity of being told nothing.\n\n>> + else{ \n\n>Style: \"else {\" \n\nOk thanks.\n\n>> + status_printf_ln(s, color, \n>> + Q_(\"Last command done (%d command done):\", \n>> + \"Last commands done (%d commands done):\", \n>> + have_done.nr), \n>> + have_done.nr); \n>> + begin = (have_done.nr > lines_to_show_nr) ? have_done.nr-lines_to_show_nr : 0; \n>> + for (i = begin; i < have_done.nr; i++) { \n>> + status_printf_ln(s, color, \" %s\", have_done.items[i].string); \n>> + } \n\n>Hmm, perhaps fold lines like this (and you do not need \"begin\")? \n\n>for (i = (lines_to_show_nr < have_done.nr) \n>? have_done.nr - lines_to_show_nr : 0; \n>i < have_done.nr; \n>i++) \n>status_printf_ln(...);\n\n\n\n>> + if (have_done.nr > lines_to_show_nr && s->hints) \n>> + status_printf_ln(s, color, \n>> + _(\" (see more in file %s)\"), git_path(\"rebase-merge/done\")); \n\n>That's a nice touch ;-) \n\n>> + } \n>> + if (yet_to_do.nr == 0) \n>> + status_printf_ln(s, color, \n>> + _(\"No commands remaining.\")); \n\n>This I can see why we may want to say it. \n\n>> + else{ \n>> + \n>> + status_printf_ln(s, color, \n>> + Q_(\"Next command to do (%d remaining command):\", \n>> + \"Next commands to do (%d remaining commands):\", \n>> + yet_to_do.nr), \n>> + yet_to_do.nr); \n>> + for (i = 0; i < lines_to_show_nr && i < yet_to_do.nr; i++) { \n>> + status_printf_ln(s, color, \" %s\", yet_to_do.items[i].string); \n>> + } \n>> + if (s->hints) \n>> + status_printf_ln(s, color, \n>> + _(\" (use \\\"git rebase --edit-todo\\\" to view and edit)\")); \n>> + } \n\n>Make sure you do not leak memory used by two string lists here... \n\nDone, thanks again.\n"}]}