{"thread":{"id":"39519","subject":"[PATCH 3/4] status: give more information during rebase -i","startedAt":"2015-06-03T22:00:22Z","lastAt":"2015-06-09T07:33:35Z","messageCount":11,"participants":["Guillaume Pagès","Matthieu Moy","Junio C Hamano","Guillaume Pages"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"262924","messageId":"1433368825-24617-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39519","inReplyTo":null,"subject":"[PATCH 1/4] status: factor two rebase-related messages together","fromName":"Guillaume Pagès","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-03T22:00:22Z","receivedAt":"2015-06-03T22:00:22Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"---\n wt-status.c | 30 +++++++++++-------------------\n 1 file changed, 11 insertions(+), 19 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 33452f1..fec6e85 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1032,7 +1032,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n {\n \tstruct stat st;\n \n-\tif (has_unmerged(s)) {\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 +1042,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_(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n+\t\t\t\tstatus_printf_ln(s, color,\n+\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_(\"  (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_(\"  (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-- \n2.4.2.342.g3cebd9b\n"},{"id":"262925","messageId":"1433368825-24617-2-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39519","inReplyTo":"1433368825-24617-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"[PATCH 2/4] status: differentiate interactive from non-interactive rebases","fromName":"Guillaume Pagès","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-03T22:00:23Z","receivedAt":"2015-06-03T22:00:23Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"---\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 fec6e85..c83eca5 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1319,7 +1319,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.342.g3cebd9b\n"},{"id":"262923","messageId":"1433368825-24617-3-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39519","inReplyTo":"1433368825-24617-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","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-03T22:00:24Z","receivedAt":"2015-06-03T22:00:24Z","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 t/t7512-status-help.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.c            |  90 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 201 insertions(+)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex 190656d..4dd201a 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(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 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,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 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@@ -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 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@@ -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 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 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 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 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 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 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,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 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@@ -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 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@@ -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 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@@ -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 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)\ndiff --git a/wt-status.c b/wt-status.c\nindex c83eca5..35ca55e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1026,12 +1026,102 @@ 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+\tstruct strbuf buf = STRBUF_INIT;\n+\tFILE *fp;\n+\n+\t*numlines = 0;\n+\tfp = 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+\tfclose(fp);\n+}\n+\n+void get_two_first_lines(char *filename, int *numlines, char **lines)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;;\n+\tchar *line;\n+\tFILE *fp;\n+\n+\n+\t*numlines = 0;\n+\tfp = 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+\tfclose(fp);\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 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+\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.g3cebd9b\n"},{"id":"262926","messageId":"1433368825-24617-4-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","threadId":"39519","inReplyTo":"1433368825-24617-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-03T22:00:25Z","receivedAt":"2015-06-03T22:00:25Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"---\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 4dd201a..dff912b 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(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+       cat >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.342.g3cebd9b\n"},{"id":"262935","messageId":"vpqfv67zylq.fsf@anie.imag.fr","threadId":"39519","inReplyTo":"1433368825-24617-3-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-04T08:06:41Z","receivedAt":"2015-06-04T08:06:41Z","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> +  (use git rebase --edit-todo to view and edit)\n\nYou're still missing double-quotes around \"git rebase --edit-todo\".\n\nGuillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> +Last command(s) done (1 command(s) done):\n\nCan't we just have \"1 command\"/\"2 commands\" instead of this (s). It's\nparticularly bad since it is already within parenthesis.\n\nSee the doc for Q_() in po/README and\nhttp://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Plural-forms.html\nfor more details.\n\n> +void get_two_last_lines(char *filename, int *numlines, char **lines)\n> +{\n> +\tstruct strbuf buf = STRBUF_INIT;\n> +\tFILE *fp;\n> +\n> +\t*numlines = 0;\n> +\tfp = 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> +\tfclose(fp);\n> +}\n> +\n> +void get_two_first_lines(char *filename, int *numlines, char **lines)\n> +{\n> +\tstruct strbuf buf = STRBUF_INIT;;\n> +\tchar *line;\n> +\tFILE *fp;\n> +\n> +\n> +\t*numlines = 0;\n> +\tfp = 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> +\tfclose(fp);\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 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\nspace after comma.\n\nYou may want to play with clang-format/clang-format-diff to have a tool\ntell you this instead of asking a human.\n\nI think english people would make this plural (No commands done).\n\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\nQ_() ?\n\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\nI'd write explicitly 'in file ...' instead of 'at'.\n\nYou need to use git_path here, it may not be \".git\" in some contexts.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"262936","messageId":"vpq6173zydu.fsf@anie.imag.fr","threadId":"39519","inReplyTo":"1433368825-24617-4-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [PATCH 4/4] status: add new tests for status during rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-04T08:11:25Z","receivedAt":"2015-06-04T08:11:25Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"I'd swap 3/4 and 4/4 so that we see the impact of your code on these new\ntests. I won't insist on that though.\n\nPlease help reviewers by explaining in the commit message why these\ntests are needed (what was not covered properly by existing tests?)\n\nGuillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:\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\nSpace before &&\n\n(same on second test)\n\n> +       cat >expected <<EOF &&\n\nIndent with spaces.\n\nI did not do a thourough review, but this version looks much, much nicer\nthan the previous one (see how PATCH 1/4 and PATCH 2/4 are nice now?).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"262965","messageId":"xmqqtwunv1bv.fsf@gitster.dls.corp.google.com","threadId":"39519","inReplyTo":"vpqfv67zylq.fsf@anie.imag.fr","subject":"Re: [PATCH 3/4] status: give more information during rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-04T17:19:00Z","receivedAt":"2015-06-04T17:19:00Z","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>> +void get_two_last_lines(char *filename, int *numlines, char **lines)\n>> +{\n>> +...\n>> +}\n>> +\n>> +void get_two_first_lines(char *filename, int *numlines, char **lines)\n>> +{\n>> +...\n>> +}\n\nI had a handful of comments on these:\n\n - Do we need two separate and overly specific functions like these,\n   i.e. \"two\" and \"first/last\"?\n\n - Wouldn't people want to be able to configure the number of lines?\n\n - Do we really want get_two_{first,last}_LINES() functions?\n\n   I am wondering if insn sheets these functions read include\n   comments, in which case get_n_{first,last}_commands() may be a\n   more correct name.\n\n - Wouldn't it be necessary for these functions to report the total\n   number of commands, instead of giving \"void\" back?  Otherwise how\n   would the caller produce summary like this:\n\n       An interactive rebase of 14 commits in progress.  You have\n       replayed 4 commits so far, the last few of which were:\n\n          da66b27 remote.c: provide per-branch pushremote name\n          f052154 remote.c: hoist branch.*.remote lookup out of\n\n       and 10 more commits to go, the next few of which are:\n\n          a9f9f8c remote.c: introduce branch_get_upstream helper\n          8770e6f remote.c: hoist read_config into remote_get_1\n       \n   Note that I am not suggesting the phrasing or presentation.  The\n   information content is what I am interested in.\n"},{"id":"263033","messageId":"261867654.193546.1433522151490.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39519","inReplyTo":"xmqqtwunv1bv.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-05T16:35:51Z","receivedAt":"2015-06-05T16:35:51Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> writes\n\n>Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes: \n\n>>> +void get_two_last_lines(char *filename, int *numlines, char **lines) \n>>> +{ \n>>> +... \n>>> +} \n>>> + \n>>> +void get_two_first_lines(char *filename, int *numlines, char **lines) \n>>> +{ \n>>> +... \n>>> +} \n\n>I had a handful of comments on these: \n\n>- Do we need two separate and overly specific functions like these, \n>i.e. \"two\" and \"first/last\"? \n\n>- Wouldn't people want to be able to configure the number of lines? \n\n>- Do we really want get_two_{first,last}_LINES() functions? \n\n>I am wondering if insn sheets these functions read include \n>comments, in which case get_n_{first,last}_commands() may be a \n>more correct name. \n\n>- Wouldn't it be necessary for these functions to report the total \n>number of commands, instead of giving \"void\" back? Otherwise how \n>would the caller produce summary like this: \n\nI felt that was not the right way to do so. What do you think of a\nfunction like that:\n\n/*\n * Puts nb_commands commands from filename in lines,\n * returns the total number of commands in the file\n * ignores comments and empty lines\n * lines needs to be at least of size nb_commands\n * part: 0 get last commands\n * \t 1 get first commands\n */\n\nint get_commands(char *filename, int nb_commands, char **lines, int part)\n\nMaybe part is not the best word to choose to take the beginning or the end\nof the file. I also hesitate about adding a parameter to ignore or not the \ncomments.\n"},{"id":"263041","messageId":"xmqqpp5arsgf.fsf@gitster.dls.corp.google.com","threadId":"39519","inReplyTo":"261867654.193546.1433522151490.JavaMail.zimbra@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-05T17:11:12Z","receivedAt":"2015-06-05T17:11:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Guillaume Pages <guillaume.pages@ensimag.grenoble-inp.fr> writes:\n\n> I felt that was not the right way to do so. What do you think of a\n> function like that:\n>\n> /*\n>  * Puts nb_commands commands from filename in lines,\n>  * returns the total number of commands in the file\n>  * ignores comments and empty lines\n>  * lines needs to be at least of size nb_commands\n>  * part: 0 get last commands\n>  * \t 1 get first commands\n>  */\n>\n> int get_commands(char *filename, int nb_commands, char **lines, int part)\n>\n> Maybe part is not the best word to choose to take the beginning or the end\n> of the file. I also hesitate about adding a parameter to ignore or not the \n> comments.\n\nIf I were doing the caller of these two functions, then instead of\nadding these specialized helpers, I'd probably structure that caller\nthis way:\n\n\tstruct strbuf buf = STRBUF_INIT;\n\tstruct string_list have_done = STRING_LIST_INIT_DUP;\n\tstruct string_list yet_to_do = STRING_LIST_INIT_DUP;\n\tint have_done_nr, yet_to_do_nr;\n\n\tstrbuf_read_file(&buf, \".../done\", 0);\n\tstripspace(&buf, 1);\n        have_done_nr = string_list_split(&have_done, buf.buf, '\\n', -1);\n\tstrbuf_release(&buf);\n\n\tstrbuf_read_file(&buf, \".../todo\", 0);\n\tstripspace(&buf, 1);\n        yet_to_do_nr = string_list_split(&yet_to_do, buf.buf, '\\n', -1);\n\tstrbuf_release(&buf);\n\nThen have_done.items[have_done_nr - 1].string would be the last one\nthat we have replayed, and yet_to_do.items[0].string would be the\nnext one we are going to replay.\n"},{"id":"263314","messageId":"xmqqbngp97yp.fsf@gitster.dls.corp.google.com","threadId":"39519","inReplyTo":"1433368825-24617-1-git-send-email-guillaume.pages@ensimag.grenoble-inp.fr","subject":"Re: [PATCH 1/4] status: factor two rebase-related messages together","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-08T22:00:14Z","receivedAt":"2015-06-08T22:00:14Z","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> ---\n>  wt-status.c | 30 +++++++++++-------------------\n>  1 file changed, 11 insertions(+), 19 deletions(-)\n\n\nHmmm, it obviously does not break anything but it is not obvious why\nthis is a good change.\n\nIs it that you wanted to have a single instance of \"if on a branch,\nwe say 'you are rebasing that branch', otherwise we say 'you are\nrebasing'\"?  Even then, I am not sure if this code movement was the\nbest way to do so (an obvious alternative is to use a shared helper\nfunction and call from the two arms of if/elseif/... chain).\n\n>\n> diff --git a/wt-status.c b/wt-status.c\n> index 33452f1..fec6e85 100644\n> --- a/wt-status.c\n> +++ b/wt-status.c\n> @@ -1032,7 +1032,7 @@ static void show_rebase_in_progress(struct wt_status *s,\n>  {\n>  \tstruct stat st;\n>  \n> -\tif (has_unmerged(s)) {\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 +1042,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_(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n> +\t\t\t\tstatus_printf_ln(s, color,\n> +\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_(\"  (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_(\"  (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"},{"id":"263326","messageId":"968122035.288953.1433835215140.JavaMail.zimbra@ensimag.grenoble-inp.fr","threadId":"39519","inReplyTo":"xmqqbngp97yp.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/4] status: factor two rebase-related messages together","fromName":"Guillaume Pages","fromEmail":"guillaume.pages@ensimag.grenoble-inp.fr","sentAt":"2015-06-09T07:33:35Z","receivedAt":"2015-06-09T07:33:35Z","isPatch":true,"sender":{"key":"guillaume.pages@ensimag.grenoble-inp.fr","avatar":null},"body":"\"Junio C Hamano\" <gitster@pobox.com> writes:\n\n>Hmmm, it obviously does not break anything but it is not obvious why \n>this is a good change. \n\n>Is it that you wanted to have a single instance of \"if on a branch, \n>we say 'you are rebasing that branch', otherwise we say 'you are \n>rebasing'\"? Even then, I am not sure if this code movement was the \n>best way to do so (an obvious alternative is to use a shared helper \n>function and call from the two arms of if/elseif/... chain). \n\nI made this change because at first sight, this piece of code was \ndifficult to read for me. There was two long branches very similar\nand I had to spot the differences, and the actual differences were\nat the very end of the branches so I had to check back what the\ncondition was about. It seems now much more natural to me: the part\nin common of both branches is in OR-condition and the differences \nbetween branches are gathered with the test on the variable they\ndepend.\n\nBy the way, I agree that this change is not absolutely necessary.\n"}]}