[PATCH 3/4] status: give more information during rebase -i

2015-06-09 Thread Guillaume Pagès
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.pa...@ensimag.grenoble-inp.fr
---
 t/t7512-status-help.sh | 111 +
 wt-status.c|  64 
 2 files changed, 175 insertions(+)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 190656d..0c889fa 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 
 interactive rebase in progress; onto $ONTO
+Last command done (1 command done):
+   pick $LAST_COMMIT one_second
+No commands 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 
 interactive rebase in progress; onto $ONTO
+Last command done (1 command done):
+   pick $LAST_COMMIT one_second
+No commands remaining.
 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on 
'\''$ONTO'\''.
   (all conflicts fixed: run git rebase --continue)
 
@@ -183,7 +191,9 @@ 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 
@@ -191,6 +201,10 @@ test_expect_success 'status when rebasing -i in edit mode' 
'
git rebase -i HEAD~2 
cat expected EOF 
 interactive rebase in progress; onto $ONTO
+Last commands done (2 commands done):
+   pick $COMMIT2 two_rebase_i
+   edit $COMMIT3 three_rebase_i
+No commands 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 
@@ -217,6 +234,12 @@ test_expect_success 'status when splitting a commit' '
git reset HEAD^ 
cat expected EOF 
 interactive rebase in progress; onto $ONTO
+Last commands done (2 commands done):
+   pick $COMMIT2 two_split
+   edit $COMMIT3 three_split
+Next command to do (1 remaining command):
+   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 
@@ -248,6 +273,11 @@ test_expect_success 'status after editing the last commit 
with --amend during a
git commit --amend -m foo 
cat expected EOF 
 interactive rebase in progress; onto $ONTO
+Last commands done (3 commands done):
+   pick $COMMIT3 three_amend
+   edit $COMMIT4 four_amend
+  (see more

[PATCH 1/4] status: factor two rebase-related messages together

2015-06-09 Thread Guillaume Pagès
Signed-off-by: Guillaume Pagès guillaume.pa...@ensimag.grenoble-inp.fr
---
 wt-status.c | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 33452f1..c239132 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1025,6 +1025,19 @@ static int split_commit_in_progress(struct wt_status *s)
free(rebase_orig_head);
return split_in_progress;
 }
+static void print_rebase_state(struct wt_status *s,
+   struct wt_status_state *state,
+   const char *color)
+{
+   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.));
+}
 
 static void show_rebase_in_progress(struct wt_status *s,
struct wt_status_state *state,
@@ -1033,14 +1046,7 @@ static void show_rebase_in_progress(struct wt_status *s,
struct stat st;
 
if (has_unmerged(s)) {
-   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.));
+   print_rebase_state(s, state, color);
if (s-hints) {
status_printf_ln(s, color,
_(  (fix conflicts and then run \git rebase 
--continue\)));
@@ -1050,14 +1056,7 @@ static void show_rebase_in_progress(struct wt_status *s,
_(  (use \git rebase --abort\ to check out 
the original branch)));
}
} 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.));
+   print_rebase_state(s, state, color);
if (s-hints)
status_printf_ln(s, color,
_(  (all conflicts fixed: run \git rebase 
--continue\)));
-- 
2.4.2.342.ga3499d3

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] status: differentiate interactive from non-interactive rebases

2015-06-09 Thread Guillaume Pagès
Signed-off-by: Guillaume Pagès guillaume.pa...@ensimag.grenoble-inp.fr
---
 t/t7512-status-help.sh | 28 ++--
 wt-status.c|  5 -
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 68ad2d7..190656d 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -136,7 +136,7 @@ test_expect_success 'status during rebase -i when conflicts 
unresolved' '
ONTO=$(git rev-parse --short rebase_i_conflicts) 
test_must_fail git rebase -i rebase_i_conflicts 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -162,7 +162,7 @@ test_expect_success 'status during rebase -i after 
resolving conflicts' '
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
 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on 
'\''$ONTO'\''.
   (all conflicts fixed: run git rebase --continue)
 
@@ -190,7 +190,7 @@ test_expect_success 'status when rebasing -i in edit mode' '
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
 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)
@@ -216,7 +216,7 @@ 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
 You are currently splitting a commit while rebasing branch 
'\''split_commit'\'' on '\''$ONTO'\''.
   (Once your working directory is clean, run git rebase --continue)
 
@@ -247,7 +247,7 @@ 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
 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)
@@ -277,7 +277,7 @@ test_expect_success 'status: (continue first edit) second 
edit' '
git rebase -i HEAD~3 
git rebase --continue 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -299,7 +299,7 @@ test_expect_success 'status: (continue 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
 You are currently splitting a commit while rebasing branch 
'\''several_edits'\'' on '\''$ONTO'\''.
   (Once your working directory is clean, run git rebase --continue)
 
@@ -326,7 +326,7 @@ test_expect_success 'status: (continue first edit) second 
edit and amend' '
git rebase --continue 
git commit --amend -m foo 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -348,7 +348,7 @@ test_expect_success 'status: (amend first edit) second 
edit' '
git commit --amend -m a 
git rebase --continue 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -371,7 +371,7 @@ test_expect_success 'status: (amend 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
 You are currently splitting a commit while rebasing branch 
'\''several_edits'\'' on '\''$ONTO'\''.
   (Once your working directory is clean, run git rebase --continue)
 
@@ -399,7 +399,7

[PATCH 4/4] status: add new tests for status during rebase -i

2015-06-09 Thread Guillaume Pagès
Expand test coverage with one or more than two commands done
and with zero, one or more than two commands remaining.

Signed-off-by: Guillaume Pagès guillaume.pa...@ensimag.grenoble-inp.fr
---
 t/t7512-status-help.sh | 87 ++
 1 file changed, 87 insertions(+)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 0c889fa..cbe27f9 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -856,4 +856,91 @@ 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) 
+   test_must_fail git rebase -i HEAD~3 
+   cat expected EOF 
+interactive rebase in progress; onto $ONTO
+Last command done (1 command done):
+   exec exit 15
+No commands 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 with some white lines in done 
file' '
+   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^^) 
+   test_must_fail git rebase -i HEAD~3 
+   cat expected EOF 
+interactive rebase in progress; onto $ONTO
+Last commands done (2 commands done):
+   pick $COMMIT2 two_commit
+   exec exit 15
+Next commands to do (2 remaining commands):
+   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: two remaining commands with some white lines in 
todo file' '
+   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^^) 
+   test_must_fail git rebase -i HEAD~4 
+   cat expected EOF 
+interactive rebase in progress; onto $ONTO
+Last commands done (3 commands done):
+   pick $COMMIT2 two_commit
+   exec exit 15
+  (see more in file .git/rebase-merge/done)
+Next commands to do (2 remaining commands):
+   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.342.ga3499d3

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] status: add new tests for status during rebase -i

2015-06-08 Thread Guillaume Pagès
Expand test coverage with one or more than two commands done
and with zero, one or more than two commands remaining
---
 t/t7512-status-help.sh | 88 ++
 1 file changed, 88 insertions(+)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 0c889fa..844ba15 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -856,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 done (1 command done):
+   exec exit 15
+No commands 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 with some white lines in done 
file' '
+   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 commands done (2 commands done):
+   pick $COMMIT2 two_commit
+   exec exit 15
+Next commands to do (2 remaining commands):
+   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: two remaining commands with some white lines in 
todo file' '
+   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 commands done (3 commands done):
+   pick $COMMIT2 two_commit
+   exec exit 15
+  (see more in file .git/rebase-merge/done)
+Next commands to do (2 remaining commands):
+   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.342.gc0899ef

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] status: give more information during rebase -i

2015-06-08 Thread Guillaume Pagès
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.
---

I've applied your remarks, the way to read into file has been changed
and the  has been added. I haven't been able to configure clang-format
so I checked many times the coding style, and hope there is no more mistakes.

 t/t7512-status-help.sh | 111 +
 wt-status.c|  61 +++
 2 files changed, 172 insertions(+)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 190656d..0c889fa 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 
 interactive rebase in progress; onto $ONTO
+Last command done (1 command done):
+   pick $LAST_COMMIT one_second
+No commands 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 
 interactive rebase in progress; onto $ONTO
+Last command done (1 command done):
+   pick $LAST_COMMIT one_second
+No commands remaining.
 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on 
'\''$ONTO'\''.
   (all conflicts fixed: run git rebase --continue)
 
@@ -183,7 +191,9 @@ 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 
@@ -191,6 +201,10 @@ test_expect_success 'status when rebasing -i in edit mode' 
'
git rebase -i HEAD~2 
cat expected EOF 
 interactive rebase in progress; onto $ONTO
+Last commands done (2 commands done):
+   pick $COMMIT2 two_rebase_i
+   edit $COMMIT3 three_rebase_i
+No commands 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 
@@ -217,6 +234,12 @@ test_expect_success 'status when splitting a commit' '
git reset HEAD^ 
cat expected EOF 
 interactive rebase in progress; onto $ONTO
+Last commands done (2 commands done):
+   pick $COMMIT2 two_split
+   edit $COMMIT3 three_split
+Next command to do (1 remaining command):
+   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 
@@ -248,6 +273,11 @@ test_expect_success 'status after editing the last commit 
with --amend during a
git commit --amend -m foo 
cat expected EOF 
 interactive 

[PATCH 4/4] status: add new tests for status during rebase -i

2015-06-03 Thread Guillaume Pagès
---
 t/t7512-status-help.sh | 88 ++
 1 file changed, 88 insertions(+)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 4dd201a..dff912b 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -856,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.342.g3cebd9b

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] status: factor two rebase-related messages together

2015-06-03 Thread Guillaume Pagès
---
 wt-status.c | 30 +++---
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 33452f1..fec6e85 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1032,7 +1032,7 @@ static void show_rebase_in_progress(struct wt_status *s,
 {
struct stat st;
 
-   if (has_unmerged(s)) {
+   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 +1042,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,
-- 
2.4.2.342.g3cebd9b

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] status: differentiate interactive from non-interactive rebases

2015-06-03 Thread Guillaume Pagès
---
 t/t7512-status-help.sh | 28 ++--
 wt-status.c|  5 -
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 68ad2d7..190656d 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -136,7 +136,7 @@ test_expect_success 'status during rebase -i when conflicts 
unresolved' '
ONTO=$(git rev-parse --short rebase_i_conflicts) 
test_must_fail git rebase -i rebase_i_conflicts 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -162,7 +162,7 @@ test_expect_success 'status during rebase -i after 
resolving conflicts' '
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
 You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on 
'\''$ONTO'\''.
   (all conflicts fixed: run git rebase --continue)
 
@@ -190,7 +190,7 @@ test_expect_success 'status when rebasing -i in edit mode' '
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
 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)
@@ -216,7 +216,7 @@ 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
 You are currently splitting a commit while rebasing branch 
'\''split_commit'\'' on '\''$ONTO'\''.
   (Once your working directory is clean, run git rebase --continue)
 
@@ -247,7 +247,7 @@ 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
 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)
@@ -277,7 +277,7 @@ test_expect_success 'status: (continue first edit) second 
edit' '
git rebase -i HEAD~3 
git rebase --continue 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -299,7 +299,7 @@ test_expect_success 'status: (continue 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
 You are currently splitting a commit while rebasing branch 
'\''several_edits'\'' on '\''$ONTO'\''.
   (Once your working directory is clean, run git rebase --continue)
 
@@ -326,7 +326,7 @@ test_expect_success 'status: (continue first edit) second 
edit and amend' '
git rebase --continue 
git commit --amend -m foo 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -348,7 +348,7 @@ test_expect_success 'status: (amend first edit) second 
edit' '
git commit --amend -m a 
git rebase --continue 
cat expected EOF 
-rebase in progress; onto $ONTO
+interactive rebase in progress; onto $ONTO
 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)
@@ -371,7 +371,7 @@ test_expect_success 'status: (amend 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
 You are currently splitting a commit while rebasing branch 
'\''several_edits'\'' on '\''$ONTO'\''.
   (Once your working directory is clean, run git rebase --continue)
 
@@ -399,7 +399,7 @@ test_expect_success 'status: (amend first edit) second edit 
and amend' '
  

[PATCH 3/4] status: give more information during rebase -i

2015-06-03 Thread Guillaume Pagès
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.
---
 t/t7512-status-help.sh | 111 +
 wt-status.c|  90 +++
 2 files changed, 201 insertions(+)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index 190656d..4dd201a 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 
 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 
 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,7 +191,9 @@ 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 
@@ -191,6 +201,10 @@ test_expect_success 'status when rebasing -i in edit mode' 
'
git rebase -i HEAD~2 
cat expected EOF 
 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 
@@ -217,6 +234,12 @@ test_expect_success 'status when splitting a commit' '
git reset HEAD^ 
cat expected EOF 
 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 
@@ -248,6 +273,11 @@ test_expect_success 'status after editing the last commit 
with --amend during a
git commit --amend -m foo 
cat expected EOF 
 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 

[RFC/PATCH 2/2] status: fix tests to handle new verbose git status during rebase

2015-06-03 Thread Guillaume Pagès
Signed-off-by: Guillaume Pagès guillaume.pa...@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

[RFC/PATCH 1/2] status: give more information during rebase -i

2015-06-03 Thread Guillaume Pagès
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.pa...@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 (*numlines2)
+   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 (numlines2  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

[PATCH/RFC] create a skeleton for the command git rebase --status

2015-05-28 Thread Guillaume Pagès
It is an almost empty code I send to validate the global architecture
of this command.  I choose to write it in C because git status is
already in C and it seems that it is the current tendency to port
shell code to C. Moreover I would like to use code from wt_status to
implement this functionnality. I wrote a helper that I call from shell
script, as it is made in bisect (bisect--helper.c).

Signed-off-by: Guillaume Pagès guillaume.pa...@ensimag.grenoble-inp.fr
---
 Makefile | 2 ++
 builtin.h| 1 +
 git-rebase.sh| 7 ++-
 git.c| 1 +
 rebase--status.c | 6 ++
 rebase--status.h | 7 +++
 6 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 rebase--status.c
 create mode 100644 rebase--status.h

diff --git a/Makefile b/Makefile
index e0caec3..e3b3e63 100644
--- a/Makefile
+++ b/Makefile
@@ -853,6 +853,7 @@ LIB_OBJS += prompt.o
 LIB_OBJS += quote.o
 LIB_OBJS += reachable.o
 LIB_OBJS += read-cache.o
+LIB_OBJS += rebase--status.o
 LIB_OBJS += reflog-walk.o
 LIB_OBJS += refs.o
 LIB_OBJS += remote.o
@@ -969,6 +970,7 @@ BUILTIN_OBJS += builtin/prune-packed.o
 BUILTIN_OBJS += builtin/prune.o
 BUILTIN_OBJS += builtin/push.o
 BUILTIN_OBJS += builtin/read-tree.o
+BUILTIN_OBJS += builtin/rebase--status--helper.o
 BUILTIN_OBJS += builtin/receive-pack.o
 BUILTIN_OBJS += builtin/reflog.o
 BUILTIN_OBJS += builtin/remote.o
diff --git a/builtin.h b/builtin.h
index c47c110..5071a08 100644
--- a/builtin.h
+++ b/builtin.h
@@ -99,6 +99,7 @@ extern int cmd_prune(int argc, const char **argv, const char 
*prefix);
 extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
 extern int cmd_push(int argc, const char **argv, const char *prefix);
 extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_rebase_status__helper(int argc, const char **argv, const char 
*prefix);
 extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_remote(int argc, const char **argv, const char *prefix);
diff --git a/git-rebase.sh b/git-rebase.sh
index 47ca3b9..8454071 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,7 @@ continue!  continue
 abort! abort and check out the original branch
 skip!  skip current patch and continue
 edit-todo! edit the todo list during an interactive rebase
+status!show the status of the current rebase
 
 . git-sh-setup
 . git-sh-i18n
@@ -238,7 +239,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
-   --continue|--skip|--abort|--edit-todo)
+   --continue|--skip|--abort|--edit-todo|--status)
test $total_argc -eq 2 || usage
action=${1##--}
;;
@@ -401,6 +402,10 @@ abort)
 edit-todo)
run_specific_rebase
;;
+status)
+   git rebase--status--helper
+   die
+   ;;
 esac
 
 # Make sure no rebase is in progress
diff --git a/git.c b/git.c
index 9efd1a3..3ebc144 100644
--- a/git.c
+++ b/git.c
@@ -410,6 +410,7 @@ static struct cmd_struct commands[] = {
{ prune-packed, cmd_prune_packed, RUN_SETUP },
{ push, cmd_push, RUN_SETUP },
{ read-tree, cmd_read_tree, RUN_SETUP },
+   { rebase--status--helper, cmd_rebase_status__helper, RUN_SETUP },
{ receive-pack, cmd_receive_pack },
{ reflog, cmd_reflog, RUN_SETUP },
{ remote, cmd_remote, RUN_SETUP },
diff --git a/rebase--status.c b/rebase--status.c
new file mode 100644
index 000..d67af52
--- /dev/null
+++ b/rebase--status.c
@@ -0,0 +1,6 @@
+#include rebase--status.h
+
+int rebase_status(){
+   printf(Rebase in progress\n);
+   return 0;
+}
diff --git a/rebase--status.h b/rebase--status.h
new file mode 100644
index 000..17d22a1
--- /dev/null
+++ b/rebase--status.h
@@ -0,0 +1,7 @@
+#ifndef REBASE__STATUS_H
+#define REBASE__STATUS_H
+
+
+extern int rebase_status();
+
+#endif
-- 
2.0.5.5.g1d968ca.dirty

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH v2] create a skeleton for the command git rebase --status

2015-05-28 Thread Guillaume Pagès
Preparatory commit for a git rebase --status command. This command
will indicate the state of the process in the rebase, and the reason
why it stopped.

Signed-off-by: Guillaume Pagès guillaume.pa...@ensimag.grenoble-inp.fr
---

The observations from Matthieu Moy have been taken into account 

It is an almost empty code sent to validate the global architecture of
this command.  It is written in C because git status is already in C
and it seems that it is the current tendency to port shell code to
C. Moreover will likely use code from wt_status to implement this
functionnality. The command calls a helper from a shell script, as it
is made in bisect (bisect--helper.c).

 Makefile |  2 ++
 builtin.h|  1 +
 builtin/rebase--status--helper.c | 23 +++
 git-rebase.sh|  6 +-
 git.c|  1 +
 rebase--status.c |  6 ++
 rebase--status.h |  7 +++
 7 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 builtin/rebase--status--helper.c
 create mode 100644 rebase--status.c
 create mode 100644 rebase--status.h

diff --git a/Makefile b/Makefile
index e0caec3..e3b3e63 100644
--- a/Makefile
+++ b/Makefile
@@ -853,6 +853,7 @@ LIB_OBJS += prompt.o
 LIB_OBJS += quote.o
 LIB_OBJS += reachable.o
 LIB_OBJS += read-cache.o
+LIB_OBJS += rebase--status.o
 LIB_OBJS += reflog-walk.o
 LIB_OBJS += refs.o
 LIB_OBJS += remote.o
@@ -969,6 +970,7 @@ BUILTIN_OBJS += builtin/prune-packed.o
 BUILTIN_OBJS += builtin/prune.o
 BUILTIN_OBJS += builtin/push.o
 BUILTIN_OBJS += builtin/read-tree.o
+BUILTIN_OBJS += builtin/rebase--status--helper.o
 BUILTIN_OBJS += builtin/receive-pack.o
 BUILTIN_OBJS += builtin/reflog.o
 BUILTIN_OBJS += builtin/remote.o
diff --git a/builtin.h b/builtin.h
index c47c110..5071a08 100644
--- a/builtin.h
+++ b/builtin.h
@@ -99,6 +99,7 @@ extern int cmd_prune(int argc, const char **argv, const char 
*prefix);
 extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
 extern int cmd_push(int argc, const char **argv, const char *prefix);
 extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_rebase_status__helper(int argc, const char **argv, const char 
*prefix);
 extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_remote(int argc, const char **argv, const char *prefix);
diff --git a/builtin/rebase--status--helper.c b/builtin/rebase--status--helper.c
new file mode 100644
index 000..efda29c
--- /dev/null
+++ b/builtin/rebase--status--helper.c
@@ -0,0 +1,23 @@
+#include builtin.h
+#include cache.h
+#include parse-options.h
+#include rebase--status.h
+
+static const char * const git_rebase_status_helper_usage[] = {
+   N_(git rebase--status--helper),
+   NULL
+};
+
+int cmd_rebase_status__helper(int argc, const char **argv, const char *prefix)
+{
+   struct option options[] = {
+   
+   };
+
+   argc = parse_options(argc, argv, prefix, options,
+git_rebase_status_helper_usage, 0);
+
+
+   /* next-all */
+   return rebase_status();
+}
diff --git a/git-rebase.sh b/git-rebase.sh
index 47ca3b9..4e1f3e1 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -43,6 +43,7 @@ continue!  continue
 abort! abort and check out the original branch
 skip!  skip current patch and continue
 edit-todo! edit the todo list during an interactive rebase
+status!show the status of the current rebase
 
 . git-sh-setup
 . git-sh-i18n
@@ -238,7 +239,7 @@ do
--verify)
ok_to_skip_pre_rebase=
;;
-   --continue|--skip|--abort|--edit-todo)
+   --continue|--skip|--abort|--edit-todo|--status)
test $total_argc -eq 2 || usage
action=${1##--}
;;
@@ -401,6 +402,9 @@ abort)
 edit-todo)
run_specific_rebase
;;
+status)
+   exec git rebase--status--helper
+   ;;
 esac
 
 # Make sure no rebase is in progress
diff --git a/git.c b/git.c
index 9efd1a3..3ebc144 100644
--- a/git.c
+++ b/git.c
@@ -410,6 +410,7 @@ static struct cmd_struct commands[] = {
{ prune-packed, cmd_prune_packed, RUN_SETUP },
{ push, cmd_push, RUN_SETUP },
{ read-tree, cmd_read_tree, RUN_SETUP },
+   { rebase--status--helper, cmd_rebase_status__helper, RUN_SETUP },
{ receive-pack, cmd_receive_pack },
{ reflog, cmd_reflog, RUN_SETUP },
{ remote, cmd_remote, RUN_SETUP },
diff --git a/rebase--status.c b/rebase--status.c
new file mode 100644
index 000..1962349
--- /dev/null
+++ b/rebase--status.c
@@ -0,0 +1,6 @@
+#include rebase--status.h
+
+int rebase_status(){
+   printf(git rebase --status is not yet implemented\n);
+   return 0;
+}
diff --git a/rebase--status.h b/rebase