{"thread":{"id":"39510","subject":"[RFC/PATCH 1/2] status: give more information during rebase -i","startedAt":"2015-06-03T08:35:44Z","lastAt":"2015-06-03T19:51:31Z","messageCount":7,"participants":["Guillaume Pagès","Matthieu Moy","Junio C Hamano","Guillaume Pages"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"262848","messageId":"1433320545-14244-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39510","inReplyTo":null,"subject":"[RFC/PATCH 1/2] status: give more information during rebase -i","fromName":"Guillaume Pagès","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-03T08:35:44Z","receivedAt":"2015-06-03T08:35:44Z","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\nSigned-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n---\n\nAt the moment it only gives information during an interactive rebase. It \ndisplays full sha1 identifiers, changing to short sha1 would be better.\n\n wt-status.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 106 insertions(+), 20 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 33452f1..8a32aea 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1026,13 +1026,104 @@ static int split_commit_in_progress(struct wt_status *s)\n \treturn split_in_progress;\n }\n \n+void get_two_last_lines(char *filename,int * numlines, char ** lines)\n+{\n+\t*numlines=0;\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *fp = fopen(git_path(\"%s\", filename), \"r\");\n+\tif (!fp) {\n+\t\tstrbuf_release(&buf);\n+\t\treturn;\n+\t}\n+\twhile (strbuf_getline(&buf, fp, '\\n')!=EOF){\n+\t\t(*numlines)++;\n+\t\tlines[0]=lines[1];\n+\t\tlines[1]=strbuf_detach(&buf, NULL);\n+\t}\n+\tif (!fclose(fp))\n+\t\tstrbuf_detach(&buf, NULL);\n+\telse\n+\t\tstrbuf_release(&buf);\n+}\n+\n+void get_two_first_lines(char *filename,int * numlines, char ** lines)\n+{\n+\t*numlines=0;\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tchar *line;\n+\tFILE *fp = fopen(git_path(\"%s\", filename), \"r\");\n+\tif (!fp) {\n+\t\tstrbuf_release(&buf);\n+\t\treturn;\n+\t}\n+\twhile (strbuf_getline(&buf, fp, '\\n')!=EOF){\n+\t\tstripspace(&buf, 1);\n+\t\tline = strbuf_detach(&buf, NULL);\n+\t\tif (strcmp(line,\"\")==0)\n+\t\t\tcontinue;\n+\t\tif (*numlines<2)\n+\t\t\tlines[*numlines] = line;\n+\t\t(*numlines)++;\n+\t}\n+\tif (!fclose(fp))\n+\t\tstrbuf_detach(&buf, NULL);\n+\telse\n+\t\tstrbuf_release(&buf);\n+}\n+\n+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 numlines =0;\n+\t\tchar* lines[2];\n+\t\tget_two_last_lines(\"rebase-merge/done\", &numlines, lines);\n+\t\tif (numlines==0)\n+\t\t\tstatus_printf_ln(s,color,\"No command done.\");\n+\t\telse{\n+\t\t\tstatus_printf_ln(s,color,\n+\t\t\t\t\"Last command(s) done (%d command(s) done):\",\n+\t\t\t\tnumlines);\n+\t\t\tbegin = numlines > 1? 0 : 1;\n+\t\t\tfor (i = begin; i < 2; i++){\n+\t\t\t\tstatus_printf_ln(s,color,\"   %s\",lines[i]);\n+\t\t\t}\n+\t\t\tif (numlines>2 && s->hints )\n+\t\t\t   status_printf_ln(s,color,\n+\t\t\t\t\"  (see more at .git/rebase-merge/done)\");\n+\t\t}\n+\t\tnumlines =0;\n+\t\tget_two_first_lines(\"rebase-merge/git-rebase-todo\",\n+\t\t\t\t\t &numlines, lines);\n+\t\tif (numlines==0)\n+\t\t\tstatus_printf_ln(s,color,\n+\t\t\t\t\t \"No command remaining.\");\n+\t\telse{\n+\n+\t\t\tstatus_printf_ln(s,color,\n+\t\t\t\t\"Next command(s) to do (%d remaining command(s)):\",\n+\t\t\t\tnumlines);\n+\t\t\tbegin = numlines > 1? 0 : 1;\n+\t\t\tfor (i = 0; (i < 2 && i < numlines); i++){\n+\t\t\t\tstatus_printf(s,color,\"   %s\",lines[i]);\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-\tif (has_unmerged(s)) {\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 \t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n@@ -1042,25 +1133,17 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t\t _(\"You are currently rebasing.\"));\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-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t_(\"  (use \\\"git rebase --skip\\\" to skip this patch)\"));\n-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n+\t\t\tif (has_unmerged(s)) {\n+\t\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t\t _(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n+\t\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t\t _(\"  (use \\\"git rebase --skip\\\" to skip this patch)\"));\n+\t\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t\t _(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n+\t\t\t} else\n+\t\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t\t _(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\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\tif (s->hints)\n-\t\t\tstatus_printf_ln(s, color,\n-\t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n \t} else if (split_commit_in_progress(s)) {\n \t\tif (state->branch)\n \t\t\tstatus_printf_ln(s, color,\n@@ -1327,7 +1410,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.4.2.340.g37f3f38\n"},{"id":"262849","messageId":"1433320545-14244-2-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39510","inReplyTo":"1433320545-14244-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"[RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase","fromName":"Guillaume Pagès","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-03T08:35:45Z","receivedAt":"2015-06-03T08:35:45Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n---\n t/t7512-status-help.sh | 227 ++++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 213 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 68ad2d7..242124f 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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (1 command(s) done):\n+   pick $LAST_COMMIT one_second\n+No command 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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (1 command(s) done):\n+   pick $LAST_COMMIT one_second\n+No command remaining.\n You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n   (all conflicts fixed: run \"git rebase --continue\")\n \n@@ -183,14 +191,20 @@ 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 \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+Last command(s) done (2 command(s) done):\n+   pick $COMMIT2 two_rebase_i\n+   edit $COMMIT3 three_rebase_i\n+No command 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@@ -216,7 +233,13 @@ 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+Last command(s) done (2 command(s) done):\n+   pick $COMMIT2 two_split\n+   edit $COMMIT3 three_split\n+Next command(s) to do (1 remaining command(s)):\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@@ -247,7 +272,12 @@ 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+Last command(s) done (3 command(s) done):\n+   pick $COMMIT3 three_amend\n+   edit $COMMIT4 four_amend\n+  (see more at .git/rebase-merge/done)\n+No command 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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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-rebase in progress; onto $ONTO\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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,13 +468,22 @@ 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 \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+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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@@ -423,7 +510,13 @@ 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+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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@@ -448,7 +544,13 @@ 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+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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@@ -478,7 +583,13 @@ 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+Last command(s) done (2 command(s) done):\n+   edit $COMMIT2 two_edits\n+   edit $COMMIT3 three_edits\n+Next command(s) to do (1 remaining command(s)):\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@@ -745,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+\tcat >expected <<EOF &&\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (1 command(s) done):\n+   exec exit 15\n+No command 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, two remainings' '\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+\tcat >expected <<EOF &&\n+interactive rebase in progress; onto $ONTO\n+Last command(s) done (2 command(s) done):\n+   pick $COMMIT2 two_commit\n+   exec exit 15\n+Next command(s) to do (2 remaining command(s)):\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: more than two commands done, two remainings' '\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 command(s) done (3 command(s) done):\n+   pick $COMMIT2 two_commit\n+   exec exit 15\n+  (see more at .git/rebase-merge/done)\n+Next command(s) to do (2 remaining command(s)):\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.340.g37f3f38\n"},{"id":"262881","messageId":"vpqpp5cbtse.fsf@anie.imag.fr","threadId":"39510","inReplyTo":"1433320545-14244-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [RFC/PATCH 1/2] status: give more information during rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-03T17:12:17Z","receivedAt":"2015-06-03T17:12:17Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Hi,\n\nYour code is not C90:\n\nwt-status.c: In function ‘get_two_last_lines’:\nwt-status.c:1030:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]\n  struct strbuf buf = STRBUF_INIT;\n  ^\nwt-status.c: In function ‘get_two_first_lines’:\nwt-status.c:1050:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]\n  struct strbuf buf = STRBUF_INIT;\n  ^\n\nI have this to notice it:\n\n$ cat config.mak\nCFLAGS += -Wdeclaration-after-statement -Wall -Werror #-O0 -g\n\nGuillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> +void get_two_last_lines(char *filename,int * numlines, char ** lines)\n\nSpace after ,\n\n> +{\n> +\t*numlines=0;\n\nSpaces around =\n\n> +\tstruct strbuf buf = STRBUF_INIT;\n> +\tFILE *fp = fopen(git_path(\"%s\", filename), \"r\");\n> +\tif (!fp) {\n> +\t\tstrbuf_release(&buf);\n> +\t\treturn;\n> +\t}\n> +\twhile (strbuf_getline(&buf, fp, '\\n')!=EOF){\n\nSpaces around !=\n\nThere are many other space issues, I won't list them all.\n\n> +\t\t(*numlines)++;\n> +\t\tlines[0]=lines[1];\n> +\t\tlines[1]=strbuf_detach(&buf, NULL);\n> +\t}\n> +\tif (!fclose(fp))\n> +\t\tstrbuf_detach(&buf, NULL);\n> +\telse\n> +\t\tstrbuf_release(&buf);\n> +}\n> +\n> +void get_two_first_lines(char *filename,int * numlines, char ** lines)\n\nStick the * to the corresponding variable.\n\nDo: int *numlines\nDon't: int * numlines, int* numlines\n\nOne rationale is that when you write\n\nint *i, j;\n\nit reads \"*i is an int, and so is j\" (which is right), while\n\nint * i, j;\n\nmay read as \"both i and j are int *\" (which is not right).\n\n> +{\n> +\t*numlines=0;\n> +\tstruct strbuf buf = STRBUF_INIT;\n> +\tchar *line;\n> +\tFILE *fp = fopen(git_path(\"%s\", filename), \"r\");\n> +\tif (!fp) {\n> +\t\tstrbuf_release(&buf);\n> +\t\treturn;\n> +\t}\n> +\twhile (strbuf_getline(&buf, fp, '\\n')!=EOF){\n> +\t\tstripspace(&buf, 1);\n> +\t\tline = strbuf_detach(&buf, NULL);\n> +\t\tif (strcmp(line,\"\")==0)\n> +\t\t\tcontinue;\n> +\t\tif (*numlines<2)\n> +\t\t\tlines[*numlines] = line;\n> +\t\t(*numlines)++;\n> +\t}\n> +\tif (!fclose(fp))\n> +\t\tstrbuf_detach(&buf, NULL);\n> +\telse\n> +\t\tstrbuf_release(&buf);\n> +}\n> +\n> +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\nstatic?\n\n> +{\n> +\tif (state->rebase_interactive_in_progress){\n> +\t\tint i, begin;\n> +\t\tint numlines =0;\n> +\t\tchar* lines[2];\n> +\t\tget_two_last_lines(\"rebase-merge/done\", &numlines, lines);\n> +\t\tif (numlines==0)\n> +\t\t\tstatus_printf_ln(s,color,\"No command done.\");\n> +\t\telse{\n\nSpace before {. Several instances too.\n\n> +\t\t\tstatus_printf_ln(s,color,\n> +\t\t\t\t\"Last command(s) done (%d command(s) done):\",\n> +\t\t\t\tnumlines);\n> +\t\t\tbegin = numlines > 1? 0 : 1;\n> +\t\t\tfor (i = begin; i < 2; i++){\n> +\t\t\t\tstatus_printf_ln(s,color,\"   %s\",lines[i]);\n> +\t\t\t}\n> +\t\t\tif (numlines>2 && s->hints )\n> +\t\t\t   status_printf_ln(s,color,\n> +\t\t\t\t\"  (see more at .git/rebase-merge/done)\");\n> +\t\t}\n> +\t\tnumlines =0;\n> +\t\tget_two_first_lines(\"rebase-merge/git-rebase-todo\",\n> +\t\t\t\t\t &numlines, lines);\n> +\t\tif (numlines==0)\n> +\t\t\tstatus_printf_ln(s,color,\n\nSpace after ,.\n\n> +\t\t\t\t\t \"No command remaining.\");\n> +\t\telse{\n> +\n> +\t\t\tstatus_printf_ln(s,color,\n> +\t\t\t\t\"Next command(s) to do (%d remaining command(s)):\",\n> +\t\t\t\tnumlines);\n> +\t\t\tbegin = numlines > 1? 0 : 1;\n> +\t\t\tfor (i = 0; (i < 2 && i < numlines); i++){\n> +\t\t\t\tstatus_printf(s,color,\"   %s\",lines[i]);\n> +\t\t\t}\n> +\t\t\tif (s->hints )\n\nNo space before ).\n\n> +\t\t\t   status_printf_ln(s,color,\n> +\t\t\t\t\"  (use git rebase --edit-todo to view and edit)\");\n\nMark for translation -> _(\"...\"). Many instances above.\n\n> -\tif (has_unmerged(s)) {\n> +\tshow_rebase_information(s,state,color);\n> +\tif (has_unmerged(s) || state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n\nThe show_rebase_information() line does belong to this patch, but the\nother change do not IHMO. It would be _much_ easier to review in its own\npatch with an explicit title like \"status: factor two rebase-related\nmessages together\" or so.\n\n> @@ -1327,7 +1410,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\nI wouldn't insist on that, but splitting this one in a separate patch\nwould make sense to me too. The patch would contain this change, and the\nimpact on tests.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"262883","messageId":"vpqh9qobtf3.fsf@anie.imag.fr","threadId":"39510","inReplyTo":"1433320545-14244-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [RFC/PATCH 1/2] status: give more information during rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-03T17:20:16Z","receivedAt":"2015-06-03T17:20:16Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> +\tif (!fclose(fp))\n> +\t\tstrbuf_detach(&buf, NULL);\n> +\telse\n> +\t\tstrbuf_release(&buf);\n\nWhy these two cases? Aren't you leaking the buffer when calling\nstrbuf_detach and ignoring its return value?\n\n(In general, there's not much to do when fclose fails actually)\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"262890","messageId":"vpqmw0gadth.fsf@anie.imag.fr","threadId":"39510","inReplyTo":"1433320545-14244-2-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-03T17:42:34Z","receivedAt":"2015-06-03T17:42:34Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n> ---\n>  t/t7512-status-help.sh | 227 ++++++++++++++++++++++++++++++++++++++++++++++---\n\nYour history is not bisectable if you sparate tests and code changes in\ntwo patches.\n\nPlus, as a reviewer, I like seeing changes to the tests next to changes\nto the code, to show me what is the impact of the code change on the\noutput of the program. In this case, this patch really shows what your\ncode is doing, and reviewing PATCH 2 means checking that we agree on the\nspecification, which should not be done _after_ checking the code.\n\n+  (use git rebase --edit-todo to view and edit)\n\nAll other status hints use double-quotes around commands. I think this\none should, too.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"262902","messageId":"xmqqvbf4wswt.fsf@gitster.dls.corp.google.com","threadId":"39510","inReplyTo":"vpqmw0gadth.fsf@anie.imag.fr","subject":"Re: [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-03T18:25:38Z","receivedAt":"2015-06-03T18:25:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n>\n>> Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>\n>> ---\n>>  t/t7512-status-help.sh | 227 ++++++++++++++++++++++++++++++++++++++++++++++---\n>\n> Your history is not bisectable if you sparate tests and code changes in\n> two patches.\n\nYes.\n\nAnd by squashing the two, you do not have to label 2/2 incorrectly\nas \"fix tests\"; it is merely fixing what 1/2 broke ;-)\n\n> Plus, as a reviewer, I like seeing changes to the tests next to changes\n> to the code, to show me what is the impact of the code change on the\n> output of the program.\n\nThat too. is a very important consideration, maybe even more so than\nbisectability.\n\nThanks.\n"},{"id":"262912","messageId":"707547885.92061.1433361091605.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39510","inReplyTo":"xmqqvbf4wswt.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase","fromName":"Guillaume Pages","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-03T19:51:31Z","receivedAt":"2015-06-03T19:51:31Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"Thanks for reviewing, I take everything into account and release a v2 ASAP.\n\nGuillaume\n"}]}