* [RFC/PATCH 1/2] status: give more information during rebase -i
@ 2015-06-03 8:35 Guillaume Pagès
2015-06-03 8:35 ` [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase Guillaume Pagès
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Guillaume Pagès @ 2015-06-03 8:35 UTC (permalink / raw)
To: git
Cc: Remi Galan, Remi Lespinet, Guillaume Pages,
Louis-Alexandre Stuber, Antoine Delaite, Matthieu Moy
git status gives more information during rebase -i, about the list of
command that are done during the rebase. It displays the two last
commands executed and the two next lines to be executed. It also gives
hints to find the whole files in .git directory.
Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>
---
At the moment it only gives information during an interactive rebase. It
displays full sha1 identifiers, changing to short sha1 would be better.
wt-status.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 106 insertions(+), 20 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 33452f1..8a32aea 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1026,13 +1026,104 @@ static int split_commit_in_progress(struct wt_status *s)
return split_in_progress;
}
+void get_two_last_lines(char *filename,int * numlines, char ** lines)
+{
+ *numlines=0;
+ struct strbuf buf = STRBUF_INIT;
+ FILE *fp = fopen(git_path("%s", filename), "r");
+ if (!fp) {
+ strbuf_release(&buf);
+ return;
+ }
+ while (strbuf_getline(&buf, fp, '\n')!=EOF){
+ (*numlines)++;
+ lines[0]=lines[1];
+ lines[1]=strbuf_detach(&buf, NULL);
+ }
+ if (!fclose(fp))
+ strbuf_detach(&buf, NULL);
+ else
+ strbuf_release(&buf);
+}
+
+void get_two_first_lines(char *filename,int * numlines, char ** lines)
+{
+ *numlines=0;
+ struct strbuf buf = STRBUF_INIT;
+ char *line;
+ FILE *fp = fopen(git_path("%s", filename), "r");
+ if (!fp) {
+ strbuf_release(&buf);
+ return;
+ }
+ while (strbuf_getline(&buf, fp, '\n')!=EOF){
+ stripspace(&buf, 1);
+ line = strbuf_detach(&buf, NULL);
+ if (strcmp(line,"")==0)
+ continue;
+ if (*numlines<2)
+ lines[*numlines] = line;
+ (*numlines)++;
+ }
+ if (!fclose(fp))
+ strbuf_detach(&buf, NULL);
+ else
+ strbuf_release(&buf);
+}
+
+void show_rebase_information(struct wt_status *s,
+ struct wt_status_state *state,
+ const char *color)
+{
+ if (state->rebase_interactive_in_progress){
+ int i, begin;
+ int numlines =0;
+ char* lines[2];
+ get_two_last_lines("rebase-merge/done", &numlines, lines);
+ if (numlines==0)
+ status_printf_ln(s,color,"No command done.");
+ else{
+ status_printf_ln(s,color,
+ "Last command(s) done (%d command(s) done):",
+ numlines);
+ begin = numlines > 1? 0 : 1;
+ for (i = begin; i < 2; i++){
+ status_printf_ln(s,color," %s",lines[i]);
+ }
+ if (numlines>2 && s->hints )
+ status_printf_ln(s,color,
+ " (see more at .git/rebase-merge/done)");
+ }
+ numlines =0;
+ get_two_first_lines("rebase-merge/git-rebase-todo",
+ &numlines, lines);
+ if (numlines==0)
+ status_printf_ln(s,color,
+ "No command remaining.");
+ else{
+
+ status_printf_ln(s,color,
+ "Next command(s) to do (%d remaining command(s)):",
+ numlines);
+ begin = numlines > 1? 0 : 1;
+ for (i = 0; (i < 2 && i < numlines); i++){
+ status_printf(s,color," %s",lines[i]);
+ }
+ if (s->hints )
+ status_printf_ln(s,color,
+ " (use git rebase --edit-todo to view and edit)");
+ }
+ }
+}
+
static void show_rebase_in_progress(struct wt_status *s,
struct wt_status_state *state,
const char *color)
{
struct stat st;
- if (has_unmerged(s)) {
+ show_rebase_information(s,state,color);
+ if (has_unmerged(s) || state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
if (state->branch)
status_printf_ln(s, color,
_("You are currently rebasing branch '%s' on '%s'."),
@@ -1042,25 +1133,17 @@ static void show_rebase_in_progress(struct wt_status *s,
status_printf_ln(s, color,
_("You are currently rebasing."));
if (s->hints) {
- status_printf_ln(s, color,
- _(" (fix conflicts and then run \"git rebase --continue\")"));
- status_printf_ln(s, color,
- _(" (use \"git rebase --skip\" to skip this patch)"));
- status_printf_ln(s, color,
- _(" (use \"git rebase --abort\" to check out the original branch)"));
+ if (has_unmerged(s)) {
+ status_printf_ln(s, color,
+ _(" (fix conflicts and then run \"git rebase --continue\")"));
+ status_printf_ln(s, color,
+ _(" (use \"git rebase --skip\" to skip this patch)"));
+ status_printf_ln(s, color,
+ _(" (use \"git rebase --abort\" to check out the original branch)"));
+ } else
+ status_printf_ln(s, color,
+ _(" (all conflicts fixed: run \"git rebase --continue\")"));
}
- } else if (state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
- if (state->branch)
- status_printf_ln(s, color,
- _("You are currently rebasing branch '%s' on '%s'."),
- state->branch,
- state->onto);
- else
- status_printf_ln(s, color,
- _("You are currently rebasing."));
- if (s->hints)
- status_printf_ln(s, color,
- _(" (all conflicts fixed: run \"git rebase --continue\")"));
} else if (split_commit_in_progress(s)) {
if (state->branch)
status_printf_ln(s, color,
@@ -1327,7 +1410,10 @@ void wt_status_print(struct wt_status *s)
else if (!strcmp(branch_name, "HEAD")) {
branch_status_color = color(WT_STATUS_NOBRANCH, s);
if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
- on_what = _("rebase in progress; onto ");
+ if (state.rebase_interactive_in_progress)
+ on_what = _("interactive rebase in progress; onto ");
+ else
+ on_what = _("rebase in progress; onto ");
branch_name = state.onto;
} else if (state.detached_from) {
branch_name = state.detached_from;
--
2.4.2.340.g37f3f38
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase
2015-06-03 8:35 [RFC/PATCH 1/2] status: give more information during rebase -i Guillaume Pagès
@ 2015-06-03 8:35 ` Guillaume Pagès
2015-06-03 17:42 ` Matthieu Moy
2015-06-03 17:12 ` [RFC/PATCH 1/2] status: give more information during rebase -i Matthieu Moy
2015-06-03 17:20 ` Matthieu Moy
2 siblings, 1 reply; 7+ messages in thread
From: Guillaume Pagès @ 2015-06-03 8:35 UTC (permalink / raw)
To: git
Cc: Remi Galan, Remi Lespinet, Guillaume Pages,
Louis-Alexandre Stuber, Antoine Delaite, Matthieu Moy
Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>
---
t/t7512-status-help.sh | 227 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 213 insertions(+), 14 deletions(-)
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 68ad2d7..242124f 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -134,9 +134,13 @@ test_expect_success 'prepare for rebase_i_conflicts' '
test_expect_success 'status during rebase -i when conflicts unresolved' '
test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short rebase_i_conflicts) &&
+ LAST_COMMIT=$(git rev-parse rebase_i_conflicts_second) &&
test_must_fail git rebase -i rebase_i_conflicts &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (1 command(s) done):
+ pick $LAST_COMMIT one_second
+No command remaining.
You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
@@ -159,10 +163,14 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
git reset --hard rebase_i_conflicts_second &&
test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short rebase_i_conflicts) &&
+ LAST_COMMIT=$(git rev-parse rebase_i_conflicts_second) &&
test_must_fail git rebase -i rebase_i_conflicts &&
git add main.txt &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (1 command(s) done):
+ pick $LAST_COMMIT one_second
+No command remaining.
You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
(all conflicts fixed: run "git rebase --continue")
@@ -183,14 +191,20 @@ test_expect_success 'status when rebasing -i in edit mode' '
git checkout -b rebase_i_edit &&
test_commit one_rebase_i main.txt one &&
test_commit two_rebase_i main.txt two &&
+ COMMIT2=$(git rev-parse rebase_i_edit) &&
test_commit three_rebase_i main.txt three &&
+ COMMIT3=$(git rev-parse rebase_i_edit) &&
FAKE_LINES="1 edit 2" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short HEAD~2) &&
git rebase -i HEAD~2 &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ pick $COMMIT2 two_rebase_i
+ edit $COMMIT3 three_rebase_i
+No command remaining.
You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -207,8 +221,11 @@ test_expect_success 'status when splitting a commit' '
git checkout -b split_commit &&
test_commit one_split main.txt one &&
test_commit two_split main.txt two &&
+ COMMIT2=$(git rev-parse split_commit) &&
test_commit three_split main.txt three &&
+ COMMIT3=$(git rev-parse split_commit) &&
test_commit four_split main.txt four &&
+ COMMIT4=$(git rev-parse split_commit) &&
FAKE_LINES="1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
@@ -216,7 +233,13 @@ test_expect_success 'status when splitting a commit' '
git rebase -i HEAD~3 &&
git reset HEAD^ &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ pick $COMMIT2 two_split
+ edit $COMMIT3 three_split
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_split
+ (use git rebase --edit-todo to view and edit)
You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -239,7 +262,9 @@ test_expect_success 'status after editing the last commit with --amend during a
test_commit one_amend main.txt one &&
test_commit two_amend main.txt two &&
test_commit three_amend main.txt three &&
+ COMMIT3=$(git rev-parse amend_last) &&
test_commit four_amend main.txt four &&
+ COMMIT4=$(git rev-parse amend_last) &&
FAKE_LINES="1 2 edit 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
@@ -247,7 +272,12 @@ test_expect_success 'status after editing the last commit with --amend during a
git rebase -i HEAD~3 &&
git commit --amend -m "foo" &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (3 command(s) done):
+ pick $COMMIT3 three_amend
+ edit $COMMIT4 four_amend
+ (see more at .git/rebase-merge/done)
+No command remaining.
You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -273,11 +303,20 @@ test_expect_success 'status: (continue first edit) second edit' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git rebase --continue &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -294,12 +333,21 @@ test_expect_success 'status: (continue first edit) second edit and split' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git rebase --continue &&
git reset HEAD^ &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -321,12 +369,21 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git rebase --continue &&
git commit --amend -m "foo" &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -343,12 +400,21 @@ test_expect_success 'status: (amend first edit) second edit' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git commit --amend -m "a" &&
git rebase --continue &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -366,12 +432,21 @@ test_expect_success 'status: (amend first edit) second edit and split' '
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
ONTO=$(git rev-parse --short HEAD~3) &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
git rebase -i HEAD~3 &&
git commit --amend -m "b" &&
git rebase --continue &&
git reset HEAD^ &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -393,13 +468,22 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git commit --amend -m "c" &&
git rebase --continue &&
git commit --amend -m "d" &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -416,6 +500,9 @@ test_expect_success 'status: (split first edit) second edit' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git reset HEAD^ &&
@@ -423,7 +510,13 @@ test_expect_success 'status: (split first edit) second edit' '
git commit -m "e" &&
git rebase --continue &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -440,6 +533,9 @@ test_expect_success 'status: (split first edit) second edit and split' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git reset HEAD^ &&
@@ -448,7 +544,13 @@ test_expect_success 'status: (split first edit) second edit and split' '
git rebase --continue &&
git reset HEAD^ &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(Once your working directory is clean, run "git rebase --continue")
@@ -470,6 +572,9 @@ test_expect_success 'status: (split first edit) second edit and amend' '
FAKE_LINES="edit 1 edit 2 3" &&
export FAKE_LINES &&
test_when_finished "git rebase --abort" &&
+ COMMIT2=$(git rev-parse several_edits^^) &&
+ COMMIT3=$(git rev-parse several_edits^) &&
+ COMMIT4=$(git rev-parse several_edits) &&
ONTO=$(git rev-parse --short HEAD~3) &&
git rebase -i HEAD~3 &&
git reset HEAD^ &&
@@ -478,7 +583,13 @@ test_expect_success 'status: (split first edit) second edit and amend' '
git rebase --continue &&
git commit --amend -m "h" &&
cat >expected <<EOF &&
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ edit $COMMIT2 two_edits
+ edit $COMMIT3 three_edits
+Next command(s) to do (1 remaining command(s)):
+ pick $COMMIT4 four_edits
+ (use git rebase --edit-todo to view and edit)
You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
@@ -745,4 +856,92 @@ EOF
test_i18ncmp expected actual
'
+test_expect_success 'prepare for different number of commits rebased' '
+ git reset --hard master &&
+ git checkout -b several_commits &&
+ test_commit one_commit main.txt one &&
+ test_commit two_commit main.txt two &&
+ test_commit three_commit main.txt three &&
+ test_commit four_commit main.txt four
+'
+
+
+test_expect_success 'status: one command done nothing remaining' '
+ FAKE_LINES=" exec_exit_15" &&
+ export FAKE_LINES &&
+ test_when_finished "git rebase --abort" &&
+ ONTO=$(git rev-parse --short HEAD~3) &&
+ (git rebase -i HEAD~3 || true)&&
+ cat >expected <<EOF &&
+interactive rebase in progress; onto $ONTO
+Last command(s) done (1 command(s) done):
+ exec exit 15
+No command remaining.
+You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
+ (use "git commit --amend" to amend the current commit)
+ (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
+ git status --untracked-files=no >actual &&
+ test_i18ncmp expected actual
+'
+
+test_expect_success 'status: two commands done, two remainings' '
+ FAKE_LINES="1 exec_exit_15 2 3" &&
+ export FAKE_LINES &&
+ test_when_finished "git rebase --abort" &&
+ ONTO=$(git rev-parse --short HEAD~3) &&
+ COMMIT4=$(git rev-parse HEAD) &&
+ COMMIT3=$(git rev-parse HEAD^) &&
+ COMMIT2=$(git rev-parse HEAD^^) &&
+ (git rebase -i HEAD~3 || true)&&
+ cat >expected <<EOF &&
+interactive rebase in progress; onto $ONTO
+Last command(s) done (2 command(s) done):
+ pick $COMMIT2 two_commit
+ exec exit 15
+Next command(s) to do (2 remaining command(s)):
+ pick $COMMIT3 three_commit
+ pick $COMMIT4 four_commit
+ (use git rebase --edit-todo to view and edit)
+You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
+ (use "git commit --amend" to amend the current commit)
+ (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
+ git status --untracked-files=no >actual &&
+ test_i18ncmp expected actual
+'
+
+test_expect_success 'status: more than two commands done, two remainings' '
+ FAKE_LINES="1 2 exec_exit_15 3 4" &&
+ export FAKE_LINES &&
+ test_when_finished "git rebase --abort" &&
+ ONTO=$(git rev-parse --short HEAD~4) &&
+ COMMIT4=$(git rev-parse HEAD) &&
+ COMMIT3=$(git rev-parse HEAD^) &&
+ COMMIT2=$(git rev-parse HEAD^^) &&
+ (git rebase -i HEAD~4 || true)&&
+ cat >expected <<EOF &&
+interactive rebase in progress; onto $ONTO
+Last command(s) done (3 command(s) done):
+ pick $COMMIT2 two_commit
+ exec exit 15
+ (see more at .git/rebase-merge/done)
+Next command(s) to do (2 remaining command(s)):
+ pick $COMMIT3 three_commit
+ pick $COMMIT4 four_commit
+ (use git rebase --edit-todo to view and edit)
+You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''.
+ (use "git commit --amend" to amend the current commit)
+ (use "git rebase --continue" once you are satisfied with your changes)
+
+nothing to commit (use -u to show untracked files)
+EOF
+ git status --untracked-files=no >actual &&
+ test_i18ncmp expected actual
+'
+
test_done
--
2.4.2.340.g37f3f38
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 1/2] status: give more information during rebase -i
2015-06-03 8:35 [RFC/PATCH 1/2] status: give more information during rebase -i Guillaume Pagès
2015-06-03 8:35 ` [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase Guillaume Pagès
@ 2015-06-03 17:12 ` Matthieu Moy
2015-06-03 17:20 ` Matthieu Moy
2 siblings, 0 replies; 7+ messages in thread
From: Matthieu Moy @ 2015-06-03 17:12 UTC (permalink / raw)
To: Guillaume Pagès
Cc: git, Remi Galan, Remi Lespinet, Louis-Alexandre Stuber,
Antoine Delaite
Hi,
Your code is not C90:
wt-status.c: In function ‘get_two_last_lines’:
wt-status.c:1030:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
struct strbuf buf = STRBUF_INIT;
^
wt-status.c: In function ‘get_two_first_lines’:
wt-status.c:1050:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
struct strbuf buf = STRBUF_INIT;
^
I have this to notice it:
$ cat config.mak
CFLAGS += -Wdeclaration-after-statement -Wall -Werror #-O0 -g
Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:
> +void get_two_last_lines(char *filename,int * numlines, char ** lines)
Space after ,
> +{
> + *numlines=0;
Spaces around =
> + struct strbuf buf = STRBUF_INIT;
> + FILE *fp = fopen(git_path("%s", filename), "r");
> + if (!fp) {
> + strbuf_release(&buf);
> + return;
> + }
> + while (strbuf_getline(&buf, fp, '\n')!=EOF){
Spaces around !=
There are many other space issues, I won't list them all.
> + (*numlines)++;
> + lines[0]=lines[1];
> + lines[1]=strbuf_detach(&buf, NULL);
> + }
> + if (!fclose(fp))
> + strbuf_detach(&buf, NULL);
> + else
> + strbuf_release(&buf);
> +}
> +
> +void get_two_first_lines(char *filename,int * numlines, char ** lines)
Stick the * to the corresponding variable.
Do: int *numlines
Don't: int * numlines, int* numlines
One rationale is that when you write
int *i, j;
it reads "*i is an int, and so is j" (which is right), while
int * i, j;
may read as "both i and j are int *" (which is not right).
> +{
> + *numlines=0;
> + struct strbuf buf = STRBUF_INIT;
> + char *line;
> + FILE *fp = fopen(git_path("%s", filename), "r");
> + if (!fp) {
> + strbuf_release(&buf);
> + return;
> + }
> + while (strbuf_getline(&buf, fp, '\n')!=EOF){
> + stripspace(&buf, 1);
> + line = strbuf_detach(&buf, NULL);
> + if (strcmp(line,"")==0)
> + continue;
> + if (*numlines<2)
> + lines[*numlines] = line;
> + (*numlines)++;
> + }
> + if (!fclose(fp))
> + strbuf_detach(&buf, NULL);
> + else
> + strbuf_release(&buf);
> +}
> +
> +void show_rebase_information(struct wt_status *s,
> + struct wt_status_state *state,
> + const char *color)
static?
> +{
> + if (state->rebase_interactive_in_progress){
> + int i, begin;
> + int numlines =0;
> + char* lines[2];
> + get_two_last_lines("rebase-merge/done", &numlines, lines);
> + if (numlines==0)
> + status_printf_ln(s,color,"No command done.");
> + else{
Space before {. Several instances too.
> + status_printf_ln(s,color,
> + "Last command(s) done (%d command(s) done):",
> + numlines);
> + begin = numlines > 1? 0 : 1;
> + for (i = begin; i < 2; i++){
> + status_printf_ln(s,color," %s",lines[i]);
> + }
> + if (numlines>2 && s->hints )
> + status_printf_ln(s,color,
> + " (see more at .git/rebase-merge/done)");
> + }
> + numlines =0;
> + get_two_first_lines("rebase-merge/git-rebase-todo",
> + &numlines, lines);
> + if (numlines==0)
> + status_printf_ln(s,color,
Space after ,.
> + "No command remaining.");
> + else{
> +
> + status_printf_ln(s,color,
> + "Next command(s) to do (%d remaining command(s)):",
> + numlines);
> + begin = numlines > 1? 0 : 1;
> + for (i = 0; (i < 2 && i < numlines); i++){
> + status_printf(s,color," %s",lines[i]);
> + }
> + if (s->hints )
No space before ).
> + status_printf_ln(s,color,
> + " (use git rebase --edit-todo to view and edit)");
Mark for translation -> _("..."). Many instances above.
> - if (has_unmerged(s)) {
> + show_rebase_information(s,state,color);
> + if (has_unmerged(s) || state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
The show_rebase_information() line does belong to this patch, but the
other change do not IHMO. It would be _much_ easier to review in its own
patch with an explicit title like "status: factor two rebase-related
messages together" or so.
> @@ -1327,7 +1410,10 @@ void wt_status_print(struct wt_status *s)
> else if (!strcmp(branch_name, "HEAD")) {
> branch_status_color = color(WT_STATUS_NOBRANCH, s);
> if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
> - on_what = _("rebase in progress; onto ");
> + if (state.rebase_interactive_in_progress)
> + on_what = _("interactive rebase in progress; onto ");
> + else
> + on_what = _("rebase in progress; onto ");
I wouldn't insist on that, but splitting this one in a separate patch
would make sense to me too. The patch would contain this change, and the
impact on tests.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 1/2] status: give more information during rebase -i
2015-06-03 8:35 [RFC/PATCH 1/2] status: give more information during rebase -i Guillaume Pagès
2015-06-03 8:35 ` [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase Guillaume Pagès
2015-06-03 17:12 ` [RFC/PATCH 1/2] status: give more information during rebase -i Matthieu Moy
@ 2015-06-03 17:20 ` Matthieu Moy
2 siblings, 0 replies; 7+ messages in thread
From: Matthieu Moy @ 2015-06-03 17:20 UTC (permalink / raw)
To: Guillaume Pagès
Cc: git, Remi Galan, Remi Lespinet, Louis-Alexandre Stuber,
Antoine Delaite
Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:
> + if (!fclose(fp))
> + strbuf_detach(&buf, NULL);
> + else
> + strbuf_release(&buf);
Why these two cases? Aren't you leaking the buffer when calling
strbuf_detach and ignoring its return value?
(In general, there's not much to do when fclose fails actually)
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase
2015-06-03 8:35 ` [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase Guillaume Pagès
@ 2015-06-03 17:42 ` Matthieu Moy
2015-06-03 18:25 ` Junio C Hamano
0 siblings, 1 reply; 7+ messages in thread
From: Matthieu Moy @ 2015-06-03 17:42 UTC (permalink / raw)
To: Guillaume Pagès
Cc: git, Remi Galan, Remi Lespinet, Louis-Alexandre Stuber,
Antoine Delaite
Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:
> Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>
> ---
> t/t7512-status-help.sh | 227 ++++++++++++++++++++++++++++++++++++++++++++++---
Your history is not bisectable if you sparate tests and code changes in
two patches.
Plus, as a reviewer, I like seeing changes to the tests next to changes
to the code, to show me what is the impact of the code change on the
output of the program. In this case, this patch really shows what your
code is doing, and reviewing PATCH 2 means checking that we agree on the
specification, which should not be done _after_ checking the code.
+ (use git rebase --edit-todo to view and edit)
All other status hints use double-quotes around commands. I think this
one should, too.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase
2015-06-03 17:42 ` Matthieu Moy
@ 2015-06-03 18:25 ` Junio C Hamano
2015-06-03 19:51 ` Guillaume Pages
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2015-06-03 18:25 UTC (permalink / raw)
To: Matthieu Moy
Cc: Guillaume Pagès, git, Remi Galan, Remi Lespinet,
Louis-Alexandre Stuber, Antoine Delaite
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr> writes:
>
>> Signed-off-by: Guillaume Pagès <guillaume.pages@ensimag.grenoble-inp.fr>
>> ---
>> t/t7512-status-help.sh | 227 ++++++++++++++++++++++++++++++++++++++++++++++---
>
> Your history is not bisectable if you sparate tests and code changes in
> two patches.
Yes.
And by squashing the two, you do not have to label 2/2 incorrectly
as "fix tests"; it is merely fixing what 1/2 broke ;-)
> Plus, as a reviewer, I like seeing changes to the tests next to changes
> to the code, to show me what is the impact of the code change on the
> output of the program.
That too. is a very important consideration, maybe even more so than
bisectability.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase
2015-06-03 18:25 ` Junio C Hamano
@ 2015-06-03 19:51 ` Guillaume Pages
0 siblings, 0 replies; 7+ messages in thread
From: Guillaume Pages @ 2015-06-03 19:51 UTC (permalink / raw)
To: Junio C Hamano
Cc: Matthieu Moy, git, Remi Galan, Remi Lespinet,
Louis-Alexandre Stuber, Antoine Delaite
Thanks for reviewing, I take everything into account and release a v2 ASAP.
Guillaume
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-06-03 19:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-03 8:35 [RFC/PATCH 1/2] status: give more information during rebase -i Guillaume Pagès
2015-06-03 8:35 ` [RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase Guillaume Pagès
2015-06-03 17:42 ` Matthieu Moy
2015-06-03 18:25 ` Junio C Hamano
2015-06-03 19:51 ` Guillaume Pages
2015-06-03 17:12 ` [RFC/PATCH 1/2] status: give more information during rebase -i Matthieu Moy
2015-06-03 17:20 ` Matthieu Moy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox