Skip to contentSkip to conversation

status: show branch name if possible in in-progress info

PATCH In review Nguyễn Thái Ngọc Duy 4 participants 12 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 status: show branch name if possible in in-progress info

---
Seems like a good thing to do.

 t/t7512-status-help.sh | 36 +++++++++++++++----------------
 wt-status.c            | 58 ++++++++++++++++++++++++++++++++++++++++++--------
 wt-status.h            |  1 +
 3 files changed, 68 insertions(+), 27 deletions(-)
t/t7512-status-help.sh +18 -18
index b3f6eb9..096ba6f 100755
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing '\''rebase_conflicts'\''.
 	#   (fix conflicts and then run "git rebase --continue")
 	#   (use "git rebase --skip" to skip this patch)
 	#   (use "git rebase --abort" to check out the original branch)
@@ -102,7 +102,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
 	git add main.txt &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing '\''rebase_conflicts'\''.
 	#   (all conflicts fixed: run "git rebase --continue")
 	#
 	# Changes to be committed:
@@ -133,7 +133,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
 	test_must_fail git rebase -i rebase_i_conflicts &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing '\''rebase_i_conflicts_second'\''.
 	#   (fix conflicts and then run "git rebase --continue")
 	#   (use "git rebase --skip" to skip this patch)
 	#   (use "git rebase --abort" to check out the original branch)
@@ -158,7 +158,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
 	git add main.txt &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing '\''rebase_i_conflicts_second'\''.
 	#   (all conflicts fixed: run "git rebase --continue")
 	#
 	# Changes to be committed:
@@ -185,7 +185,7 @@ test_expect_success 'status when rebasing -i in edit mode' '
 	git rebase -i HEAD~2 &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''rebase_i_edit'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -210,7 +210,7 @@ test_expect_success 'status when splitting a commit' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing '\''split_commit'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -240,7 +240,7 @@ test_expect_success 'status after editing the last commit with --amend during a
 	git commit --amend -m "foo" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''amend_last'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -269,7 +269,7 @@ test_expect_success 'status: (continue first edit) second edit' '
 	git rebase --continue &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''several_edits'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -290,7 +290,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing '\''several_edits'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -316,7 +316,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
 	git commit --amend -m "foo" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''several_edits'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -337,7 +337,7 @@ test_expect_success 'status: (amend first edit) second edit' '
 	git rebase --continue &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''several_edits'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -359,7 +359,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing '\''several_edits'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -386,7 +386,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
 	git commit --amend -m "d" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''several_edits'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -409,7 +409,7 @@ test_expect_success 'status: (split first edit) second edit' '
 	git rebase --continue &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''several_edits'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -433,7 +433,7 @@ test_expect_success 'status: (split first edit) second edit and split' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing '\''several_edits'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -462,7 +462,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '
 	git commit --amend -m "h" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing '\''several_edits'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -558,7 +558,7 @@ test_expect_success 'status when bisecting' '
 	git bisect good one_bisect &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently bisecting.
+	# You are currently bisecting '\''bisect'\''.
 	#   (use "git bisect reset" to get back to the original branch)
 	#
 	nothing to commit (use -u to show untracked files)
@@ -580,7 +580,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing '\''statushints_disabled'\''.
 	#
 	# Unmerged paths:
 	#	both modified:      main.txt
wt-status.c +49 -9

114 lines not on this page · raw message

wt-status.h +1 -0
index 236b41f..c5eae29 100644
@@ -79,6 +79,7 @@ struct wt_status_state {
 	int rebase_interactive_in_progress;
 	int cherry_pick_in_progress;
 	int bisect_in_progress;
+	const char *branch;
 };
 
 void wt_status_prepare(struct wt_status *s);
Signature · 1 line
1.8.1.1.459.g5970e58
#1 lore raw

PATCH v2 1/1 status: show the branch name if possible in in-progress info

---
- fix bisecting on detached HEAD
- show onto sha-1 for rebase

 t/t7512-status-help.sh | 36 ++++++++++----------
 wt-status.c            | 91 ++++++++++++++++++++++++++++++++++++++++++++++----
 wt-status.h            |  2 ++
 3 files changed, 105 insertions(+), 24 deletions(-)
t/t7512-status-help.sh +18 -18
index b3f6eb9..67ece6b 100755
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''000106f'\''.
 	#   (fix conflicts and then run "git rebase --continue")
 	#   (use "git rebase --skip" to skip this patch)
 	#   (use "git rebase --abort" to check out the original branch)
@@ -102,7 +102,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
 	git add main.txt &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''000106f'\''.
 	#   (all conflicts fixed: run "git rebase --continue")
 	#
 	# Changes to be committed:
@@ -133,7 +133,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
 	test_must_fail git rebase -i rebase_i_conflicts &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''e0164e4'\''.
 	#   (fix conflicts and then run "git rebase --continue")
 	#   (use "git rebase --skip" to skip this patch)
 	#   (use "git rebase --abort" to check out the original branch)
@@ -158,7 +158,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
 	git add main.txt &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''e0164e4'\''.
 	#   (all conflicts fixed: run "git rebase --continue")
 	#
 	# Changes to be committed:
@@ -185,7 +185,7 @@ test_expect_success 'status when rebasing -i in edit mode' '
 	git rebase -i HEAD~2 &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''f90e540'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -210,7 +210,7 @@ test_expect_success 'status when splitting a commit' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''19b175e'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -240,7 +240,7 @@ test_expect_success 'status after editing the last commit with --amend during a
 	git commit --amend -m "foo" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''dd030b9'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -269,7 +269,7 @@ test_expect_success 'status: (continue first edit) second edit' '
 	git rebase --continue &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -290,7 +290,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -316,7 +316,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
 	git commit --amend -m "foo" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -337,7 +337,7 @@ test_expect_success 'status: (amend first edit) second edit' '
 	git rebase --continue &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -359,7 +359,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -386,7 +386,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
 	git commit --amend -m "d" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -409,7 +409,7 @@ test_expect_success 'status: (split first edit) second edit' '
 	git rebase --continue &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -433,7 +433,7 @@ test_expect_success 'status: (split first edit) second edit and split' '
 	git reset HEAD^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -462,7 +462,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '
 	git commit --amend -m "h" &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''eb16a7e'\''.
 	#   (use "git commit --amend" to amend the current commit)
 	#   (use "git rebase --continue" once you are satisfied with your changes)
 	#
@@ -558,7 +558,7 @@ test_expect_success 'status when bisecting' '
 	git bisect good one_bisect &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently bisecting.
+	# You are currently bisecting branch '\''bisect'\''.
 	#   (use "git bisect reset" to get back to the original branch)
 	#
 	nothing to commit (use -u to show untracked files)
@@ -580,7 +580,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''statushints_disabled'\'' on '\''1d51a61'\''.
 	#
 	# Unmerged paths:
 	#	both modified:      main.txt
wt-status.c +85 -6

148 lines not on this page · raw message

wt-status.h +2 -0
index 236b41f..81e1dcf 100644
@@ -79,6 +79,8 @@ struct wt_status_state {
 	int rebase_interactive_in_progress;
 	int cherry_pick_in_progress;
 	int bisect_in_progress;
+	const char *branch;
+	const char *onto;
 };
 
 void wt_status_prepare(struct wt_status *s);
Signature · 1 line
1.8.1.1.459.g5970e58
#2 lore raw

Re: [PATCH v2] status: show the branch name if possible in in-progress info

Hi Duy,

t/t7512-status-help.sh test_expect_success 'status when rebase in progress before resolving conflicts' · line 79

Quoted 8 lines · Nguyễn Thái Ngọc Duy
t/t7512-status-help.sh +1 -1
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''000106f'\''.

SHA1-in-tests radar blinking.

Would it be possible to compute the expected output, as in

	dest=$(git rev-parse --short HEAD^^)
	cat >expected <<-EOF &&
	# Not currently on any branch.
	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$dest'\''.

?

I'm not sure what to think about the actual change itself yet. Can you give an example of when you felt the need for this, so it can be included in the commit message or documentation?

Thanks.
Jonathan

author
#3 lore raw

Re: [PATCH v2] status: show the branch name if possible in in-progress info

Quoted 5 lines · Jonathan Nieder

Review

Quoted 2 lines
(quoted diff) +1 -1
-     # You are currently rebasing.
+     # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''000106f'\''.

SHA1-in-tests radar blinking.

Quoted 8 lines

Would it be possible to compute the expected output, as in

        dest=$(git rev-parse --short HEAD^^)
        cat >expected <<-EOF &&
        # Not currently on any branch.
        # You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$dest'\''.

?

That may be better. Yeah.

Quoted 3 lines

I'm not sure what to think about the actual change itself yet. Can you give an example of when you felt the need for this, so it can be included in the commit message or documentation?

http://thread.gmane.org/gmane.comp.version-control.git/214932/focus=214937

Signature · 1 line
Duy
#8 lore raw
In reply to Nguyễn Thái Ngọc Duy

I like the idea.

t/t7512-status-help.sh test_expect_success 'status when rebase in progress before resolving conflicts' · line 79

Quoted 10 lines · Nguyễn Thái Ngọc Duy
t/t7512-status-help.sh +1 -1
index b3f6eb9..096ba6f 100755
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing '\''rebase_conflicts'\''.

Perhaps "rebasing *branch* 'rebase_conflicts'"

Or even "rebasing branch 'rebase_conflicts' on <sha1sum>"

?

t/t7512-status-help.sh static void show_bisect_in_progress(struct wt_status *s, · line 953

Quoted 9 lines
t/t7512-status-help.sh +1 -1
@@ -923,7 +947,7 @@ static void show_bisect_in_progress(struct wt_status *s,
 				struct wt_status_state *state,
 				const char *color)
 {
-	status_printf_ln(s, color, _("You are currently bisecting."));
+	status_printf_ln(s, color, _("You are currently bisecting '%s'."), state->branch);
 	if (advice_status_hints)
 		status_printf_ln(s, color,
 			_("  (use \"git bisect reset\" to get back to the original branch)"));

In the "rebase" case, you test state->branch for null-ness. Don't you need the same test here? (What happens if you start a bisect from a detached HEAD state?)

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
author
#9 lore raw
Quoted 4 lines · Matthieu Moy

I like the idea.

Nguyễn Thái Ngọc Duy <[email protected]> writes:

Quoted 12 lines

t/t7512-status-help.sh test_expect_success 'status when rebase in progress before resolving conflicts' · line 79

Quoted 10 lines
t/t7512-status-help.sh +1 -1
index b3f6eb9..096ba6f 100755
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
      test_must_fail git rebase HEAD^ --onto HEAD^^ &&
      cat >expected <<-\EOF &&
      # Not currently on any branch.
-     # You are currently rebasing.
+     # You are currently rebasing '\''rebase_conflicts'\''.

Perhaps "rebasing *branch* 'rebase_conflicts'"

Looks good. One minor thing, if the ref happens to be refs/somewhere-not-in-heads, should we still say "rebasing branch 'refs/...'" or just "rebasing 'refs/...'", or something else?

Quoted 2 lines

Or even "rebasing branch 'rebase_conflicts' on <sha1sum>"

<sha1sum> being SHA-1 of HEAD? Why would you need it? In short version, not full SHA-1?

Quoted 15 lines

?

t/t7512-status-help.sh static void show_bisect_in_progress(struct wt_status *s, · line 953

Quoted 9 lines
t/t7512-status-help.sh +1 -1
@@ -923,7 +947,7 @@ static void show_bisect_in_progress(struct wt_status *s,
                              struct wt_status_state *state,
                              const char *color)
 {
-     status_printf_ln(s, color, _("You are currently bisecting."));
+     status_printf_ln(s, color, _("You are currently bisecting '%s'."), state->branch);
      if (advice_status_hints)
              status_printf_ln(s, color,
                      _("  (use \"git bisect reset\" to get back to the original branch)"));

In the "rebase" case, you test state->branch for null-ness. Don't you need the same test here? (What happens if you start a bisect from a detached HEAD state?)

I did read git-bisect.sh. I did not think it allowed bisecting on detached HEAD. A simple test just told me otherwise. Will update.

Signature · 1 line
Duy
#10 lore raw
Quoted 19 lines · Duy Nguyen
Quoted 4 lines · Matthieu Moy

I like the idea.

Nguyễn Thái Ngọc Duy <[email protected]> writes:

Quoted 12 lines

t/t7512-status-help.sh test_expect_success 'status when rebase in progress before resolving conflicts' · line 79

Quoted 10 lines
t/t7512-status-help.sh +1 -1
index b3f6eb9..096ba6f 100755
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
      test_must_fail git rebase HEAD^ --onto HEAD^^ &&
      cat >expected <<-\EOF &&
      # Not currently on any branch.
-     # You are currently rebasing.
+     # You are currently rebasing '\''rebase_conflicts'\''.

Perhaps "rebasing *branch* 'rebase_conflicts'"

Quoted 3 lines

Looks good. One minor thing, if the ref happens to be refs/somewhere-not-in-heads, should we still say "rebasing branch 'refs/...'" or just "rebasing 'refs/...'", or something else?

I think this should not happen, since HEAD can either point to a branch or directly to a sha1 in normal conditions. But it doesn't harm to be defensive, in case ...

Quoted 3 lines
Quoted 1 line

Or even "rebasing branch 'rebase_conflicts' on <sha1sum>"

<sha1sum> being SHA-1 of HEAD?

Not HEAD, but .git/rebase-merge/onto, i.e. the target of the rebase. Ideally, I would have loved to see "rebasing master on origin/master", but I do not think the target ref name is stored during rebase.

Quoted 1 line

Why would you need it?

The typical use-case is starting a rebase, do something else, come back the day after and wonder wft. Which branch is being rebased is probably the most useful, but the target may help too. But I can live without ;-).

Quoted 1 line

In short version, not full SHA-1?

If you add it, the short one (long version would make overly long line with limited use).

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#11 lore raw
Quoted 3 lines · Matthieu Moy

Not HEAD, but .git/rebase-merge/onto, i.e. the target of the rebase. Ideally, I would have loved to see "rebasing master on origin/master", but I do not think the target ref name is stored during rebase.

Perhaps do it with --format=%s then. It often is useless to know only the commit object name (or the branch name for that matter, as you wouldn't know what exact commit the branch tip happens to have) you are rebasing onto.

#4 lore raw

PATCH v3 1/1 status: show the branch name if possible in in-progress info

In reply to Nguyễn Thái Ngọc Duy

---
- avoid hardcoding SHA-1 in t7512
- I did not act on Junio's --format=%s idea because frankly I don't care much about the "on 'xxx'" part. It was Matthieu's idea and he did not make any comments on --format=%s

 t/t7512-status-help.sh | 87 +++++++++++++++++++++++++++-------------------
 wt-status.c            | 94 ++++++++++++++++++++++++++++++++++++++++++++++----
 wt-status.h            |  2 ++
 3 files changed, 142 insertions(+), 41 deletions(-)
t/t7512-status-help.sh +52 -35
index b3f6eb9..51ab894 100755
@@ -73,10 +73,11 @@ test_expect_success 'prepare for rebase conflicts' '
 
 test_expect_success 'status when rebase in progress before resolving conflicts' '
 	test_when_finished "git rebase --abort" &&
+	ONTO=$(git rev-parse --short HEAD^^) &&
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
 	#   (fix conflicts and then run "git rebase --continue")
 	#   (use "git rebase --skip" to skip this patch)
 	#   (use "git rebase --abort" to check out the original branch)
@@ -97,12 +98,13 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
 test_expect_success 'status when rebase in progress before rebase --continue' '
 	git reset --hard rebase_conflicts &&
 	test_when_finished "git rebase --abort" &&
+	ONTO=$(git rev-parse --short HEAD^^) &&
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
 	echo three >main.txt &&
 	git add main.txt &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''.
 	#   (all conflicts fixed: run "git rebase --continue")
 	#
 	# Changes to be committed:
@@ -130,10 +132,11 @@ 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) &&
 	test_must_fail git rebase -i rebase_i_conflicts &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# 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)
 	#   (use "git rebase --abort" to check out the original branch)
@@ -154,11 +157,12 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
 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) &&
 	test_must_fail git rebase -i rebase_i_conflicts &&
 	git add main.txt &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''.
 	#   (all conflicts fixed: run "git rebase --continue")
 	#
 	# Changes to be committed:
@@ -182,10 +186,11 @@ test_expect_success 'status when rebasing -i in edit mode' '
 	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 &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -206,11 +211,12 @@ test_expect_success 'status when splitting a commit' '
 	FAKE_LINES="1 edit 2 3" &&
 	export FAKE_LINES &&
 	test_when_finished "git rebase --abort" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git reset HEAD^ &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -236,11 +242,12 @@ test_expect_success 'status after editing the last commit with --amend during a
 	FAKE_LINES="1 2 edit 3" &&
 	export FAKE_LINES &&
 	test_when_finished "git rebase --abort" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git commit --amend -m "foo" &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -265,11 +272,12 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git rebase --continue &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -285,12 +293,13 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git rebase --continue &&
 	git reset HEAD^ &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -311,12 +320,13 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git rebase --continue &&
 	git commit --amend -m "foo" &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -332,12 +342,13 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git commit --amend -m "a" &&
 	git rebase --continue &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -353,13 +364,14 @@ test_expect_success 'status: (amend first edit) second edit and split' '
 	FAKE_LINES="edit 1 edit 2 3" &&
 	export FAKE_LINES &&
 	test_when_finished "git rebase --abort" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git commit --amend -m "b" &&
 	git rebase --continue &&
 	git reset HEAD^ &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -380,13 +392,14 @@ 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" &&
+	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 &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -402,14 +415,15 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git reset HEAD^ &&
 	git add main.txt &&
 	git commit -m "e" &&
 	git rebase --continue &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -425,15 +439,16 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git reset HEAD^ &&
 	git add main.txt &&
 	git commit --amend -m "f" &&
 	git rebase --continue &&
 	git reset HEAD^ &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently splitting a commit during a rebase.
+	# You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''.
 	#   (Once your working directory is clean, run "git rebase --continue")
 	#
 	# Changes not staged for commit:
@@ -454,15 +469,16 @@ 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" &&
+	ONTO=$(git rev-parse --short HEAD~3) &&
 	git rebase -i HEAD~3 &&
 	git reset HEAD^ &&
 	git add main.txt &&
 	git commit --amend -m "g" &&
 	git rebase --continue &&
 	git commit --amend -m "h" &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently editing a commit during a rebase.
+	# 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)
 	#
@@ -558,7 +574,7 @@ test_expect_success 'status when bisecting' '
 	git bisect good one_bisect &&
 	cat >expected <<-\EOF &&
 	# Not currently on any branch.
-	# You are currently bisecting.
+	# You are currently bisecting branch '\''bisect'\''.
 	#   (use "git bisect reset" to get back to the original branch)
 	#
 	nothing to commit (use -u to show untracked files)
@@ -577,10 +593,11 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
 	test_commit two_statushints main.txt two &&
 	test_commit three_statushints main.txt three &&
 	test_when_finished "git rebase --abort" &&
+	ONTO=$(git rev-parse --short HEAD^^) &&
 	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
-	cat >expected <<-\EOF &&
+	cat >expected <<-EOF &&
 	# Not currently on any branch.
-	# You are currently rebasing.
+	# You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''.
 	#
 	# Unmerged paths:
 	#	both modified:      main.txt
wt-status.c +88 -6

151 lines not on this page · raw message

wt-status.h +2 -0
index 236b41f..81e1dcf 100644
@@ -79,6 +79,8 @@ struct wt_status_state {
 	int rebase_interactive_in_progress;
 	int cherry_pick_in_progress;
 	int bisect_in_progress;
+	const char *branch;
+	const char *onto;
 };
 
 void wt_status_prepare(struct wt_status *s);
Signature · 1 line
1.8.1.1.459.g5970e58
#5 lore raw

Re: [PATCH v3] status: show the branch name if possible in in-progress info

Quoted 1 line · Nguyễn Thái Ngọc Duy

Missing description. Stealing from the link you sent:

The typical use-case is starting a rebase, do something else, come back the day after, run "git status" or make a new commit and wonder what in the world's going on. Which branch is being rebased is probably the most useful tidbit to help, but the target may help too.

Ideally, I would have loved to see "rebasing master on origin/master", but the target ref name is not stored during rebase, so this patch writes "rebasing master on a78c8c98b" as a half-measure to remind future users of that potential improvement.

Signed-off-by <...>
author
#6 lore raw

Re: [PATCH v3] status: show the branch name if possible in in-progress info

Quoted 7 lines · Jonathan Nieder

Missing description. Stealing from the link you sent:

The typical use-case is starting a rebase, do something else, come back the day after, run "git status" or make a new commit and wonder what in the world's going on. Which branch is being rebased is probably the most useful tidbit to help, but the target may help too.

Quoted 6 lines

Ideally, I would have loved to see "rebasing master on origin/master", but the target ref name is not stored during rebase, so this patch writes "rebasing master on a78c8c98b" as a half-measure to remind future users of that potential improvement.

Signed-off-by <...>

Looking good. Junio, do you need a new patch mail or can you just amend the commit message?

Signature · 1 line
Duy
#7 lore raw

Re: [PATCH v3] status: show the branch name if possible in in-progress info

Quoted 13 lines · Duy Nguyen
Quoted 12 lines · Jonathan Nieder

Missing description. Stealing from the link you sent:

The typical use-case is starting a rebase, do something else, come back the day after, run "git status" or make a new commit and wonder what in the world's going on. Which branch is being rebased is probably the most useful tidbit to help, but the target may help too.

Ideally, I would have loved to see "rebasing master on origin/master", but the target ref name is not stored during rebase, so this patch writes "rebasing master on a78c8c98b" as a half-measure to remind future users of that potential improvement.

Quoted 4 lines
Quoted 1 line
        Signed-off-by: <...>

Looking good. Junio, do you need a new patch mail or can you just amend the commit message?

I'd like to see you either

- send a reroll, making it clear it is a reroll, or
- tell me to amend.

instead of asking which one I would prefer ;-) One less message I have to respond to that way.

"commit --amend" done.