git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] status: show branch name if possible in in-progress info
@ 2013-01-29 12:10 Nguyễn Thái Ngọc Duy
  2013-01-29 12:31 ` Matthieu Moy
  2013-01-29 14:58 ` [PATCH v2] status: show the " Nguyễn Thái Ngọc Duy
  0 siblings, 2 replies; 12+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2013-01-29 12:10 UTC (permalink / raw)
  To: git; +Cc: Matthieu Moy, Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 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(-)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index b3f6eb9..096ba6f 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -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
diff --git a/wt-status.c b/wt-status.c
index d7cfe8f..cc7e2d7 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -872,7 +872,13 @@ static void show_rebase_in_progress(struct wt_status *s,
 	struct stat st;
 
 	if (has_unmerged(s)) {
-		status_printf_ln(s, color, _("You are currently rebasing."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently rebasing '%s'."),
+					 state->branch);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently rebasing."));
 		if (advice_status_hints) {
 			status_printf_ln(s, color,
 				_("  (fix conflicts and then run \"git rebase --continue\")"));
@@ -882,17 +888,35 @@ 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)) {
-		status_printf_ln(s, color, _("You are currently rebasing."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently rebasing '%s'."),
+					 state->branch);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently rebasing."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (all conflicts fixed: run \"git rebase --continue\")"));
 	} else if (split_commit_in_progress(s)) {
-		status_printf_ln(s, color, _("You are currently splitting a commit during a rebase."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently splitting a commit while rebasing '%s'."),
+					 state->branch);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently splitting a commit during a rebase."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (Once your working directory is clean, run \"git rebase --continue\")"));
 	} else {
-		status_printf_ln(s, color, _("You are currently editing a commit during a rebase."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently editing a commit while rebasing '%s'."),
+					 state->branch);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently editing a commit during a rebase."));
 		if (advice_status_hints && !s->amend) {
 			status_printf_ln(s, color,
 				_("  (use \"git commit --amend\" to amend the current commit)"));
@@ -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)"));
@@ -935,6 +959,7 @@ static void wt_status_print_state(struct wt_status *s)
 	const char *state_color = color(WT_STATUS_HEADER, s);
 	struct wt_status_state state;
 	struct stat st;
+	struct strbuf sb = STRBUF_INIT;
 
 	memset(&state, 0, sizeof(state));
 
@@ -947,28 +972,43 @@ static void wt_status_print_state(struct wt_status *s)
 				state.am_empty_patch = 1;
 		} else {
 			state.rebase_in_progress = 1;
+			strbuf_read_file(&sb, git_path("rebase-apply/head-name"), 0);
 		}
 	} else if (!stat(git_path("rebase-merge"), &st)) {
 		if (!stat(git_path("rebase-merge/interactive"), &st))
 			state.rebase_interactive_in_progress = 1;
 		else
 			state.rebase_in_progress = 1;
+		strbuf_read_file(&sb, git_path("rebase-merge/head-name"), 0);
 	} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
 		state.cherry_pick_in_progress = 1;
 	}
-	if (!stat(git_path("BISECT_LOG"), &st))
+	if (!stat(git_path("BISECT_LOG"), &st)) {
+		strbuf_read_file(&sb, git_path("BISECT_START"), 0);
 		state.bisect_in_progress = 1;
+	}
 
 	if (state.merge_in_progress)
 		show_merge_in_progress(s, &state, state_color);
 	else if (state.am_in_progress)
 		show_am_in_progress(s, &state, state_color);
-	else if (state.rebase_in_progress || state.rebase_interactive_in_progress)
+	else if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
+		while (sb.len && sb.buf[sb.len - 1] == '\n')
+			strbuf_setlen(&sb, sb.len - 1);
+		if (!prefixcmp(sb.buf, "refs/heads/"))
+			state.branch = sb.buf + strlen("refs/heads/");
+		else if (!prefixcmp(sb.buf, "refs/"))
+			state.branch = sb.buf;
 		show_rebase_in_progress(s, &state, state_color);
-	else if (state.cherry_pick_in_progress)
+	} else if (state.cherry_pick_in_progress)
 		show_cherry_pick_in_progress(s, &state, state_color);
-	if (state.bisect_in_progress)
+	if (state.bisect_in_progress) {
+		while (sb.len && sb.buf[sb.len - 1] == '\n')
+			strbuf_setlen(&sb, sb.len - 1);
+		state.branch = sb.buf;
 		show_bisect_in_progress(s, &state, state_color);
+	}
+	strbuf_release(&sb);
 }
 
 void wt_status_print(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index 236b41f..c5eae29 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -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);
-- 
1.8.1.1.459.g5970e58

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] status: show branch name if possible in in-progress info
  2013-01-29 12:10 [PATCH] status: show branch name if possible in in-progress info Nguyễn Thái Ngọc Duy
@ 2013-01-29 12:31 ` Matthieu Moy
  2013-01-29 12:56   ` Duy Nguyen
  2013-01-29 14:58 ` [PATCH v2] status: show the " Nguyễn Thái Ngọc Duy
  1 sibling, 1 reply; 12+ messages in thread
From: Matthieu Moy @ 2013-01-29 12:31 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

I like the idea.

Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:

> diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
> index b3f6eb9..096ba6f 100755
> --- a/t/t7512-status-help.sh
> +++ b/t/t7512-status-help.sh
> @@ -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>"

?

> @@ -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?)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] status: show branch name if possible in in-progress info
  2013-01-29 12:31 ` Matthieu Moy
@ 2013-01-29 12:56   ` Duy Nguyen
  2013-01-29 13:13     ` Matthieu Moy
  0 siblings, 1 reply; 12+ messages in thread
From: Duy Nguyen @ 2013-01-29 12:56 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git

On Tue, Jan 29, 2013 at 7:31 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> I like the idea.
>
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
>> index b3f6eb9..096ba6f 100755
>> --- a/t/t7512-status-help.sh
>> +++ b/t/t7512-status-help.sh
>> @@ -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?

>
> 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?

> ?
>
>> @@ -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.
-- 
Duy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] status: show branch name if possible in in-progress info
  2013-01-29 12:56   ` Duy Nguyen
@ 2013-01-29 13:13     ` Matthieu Moy
  2013-01-29 16:18       ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Matthieu Moy @ 2013-01-29 13:13 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: git

Duy Nguyen <pclouds@gmail.com> writes:

> On Tue, Jan 29, 2013 at 7:31 PM, Matthieu Moy
> <Matthieu.Moy@grenoble-inp.fr> wrote:
>> I like the idea.
>>
>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>>
>>> diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
>>> index b3f6eb9..096ba6f 100755
>>> --- a/t/t7512-status-help.sh
>>> +++ b/t/t7512-status-help.sh
>>> @@ -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?

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 ...

>> 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.

> 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 ;-).

> In short version, not full SHA-1?

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

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] status: show the branch name if possible in in-progress info
  2013-01-29 12:10 [PATCH] status: show branch name if possible in in-progress info Nguyễn Thái Ngọc Duy
  2013-01-29 12:31 ` Matthieu Moy
@ 2013-01-29 14:58 ` Nguyễn Thái Ngọc Duy
  2013-01-29 18:44   ` Jonathan Nieder
  2013-02-03  5:53   ` [PATCH v3] " Nguyễn Thái Ngọc Duy
  1 sibling, 2 replies; 12+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2013-01-29 14:58 UTC (permalink / raw)
  To: git; +Cc: Matthieu Moy, Nguyễn Thái Ngọc Duy


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 - 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(-)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index b3f6eb9..67ece6b 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -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
diff --git a/wt-status.c b/wt-status.c
index d7cfe8f..42fafd0 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -872,7 +872,14 @@ static void show_rebase_in_progress(struct wt_status *s,
 	struct stat st;
 
 	if (has_unmerged(s)) {
-		status_printf_ln(s, color, _("You are currently rebasing."));
+		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 (advice_status_hints) {
 			status_printf_ln(s, color,
 				_("  (fix conflicts and then run \"git rebase --continue\")"));
@@ -882,17 +889,38 @@ 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)) {
-		status_printf_ln(s, color, _("You are currently rebasing."));
+		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 (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (all conflicts fixed: run \"git rebase --continue\")"));
 	} else if (split_commit_in_progress(s)) {
-		status_printf_ln(s, color, _("You are currently splitting a commit during a rebase."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently splitting a commit while rebasing branch '%s' on '%s'."),
+					 state->branch,
+					 state->onto);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently splitting a commit during a rebase."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (Once your working directory is clean, run \"git rebase --continue\")"));
 	} else {
-		status_printf_ln(s, color, _("You are currently editing a commit during a rebase."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently editing a commit while rebasing branch '%s' on '%s'."),
+					 state->branch,
+					 state->onto);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently editing a commit during a rebase."));
 		if (advice_status_hints && !s->amend) {
 			status_printf_ln(s, color,
 				_("  (use \"git commit --amend\" to amend the current commit)"));
@@ -923,16 +951,54 @@ 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."));
+	if (state->branch)
+		status_printf_ln(s, color,
+				 _("You are currently bisecting branch '%s'."),
+				 state->branch);
+	else
+		status_printf_ln(s, color,
+				 _("You are currently bisecting."));
 	if (advice_status_hints)
 		status_printf_ln(s, color,
 			_("  (use \"git bisect reset\" to get back to the original branch)"));
 	wt_status_print_trailer(s);
 }
 
+static void read_and_strip_branch(struct strbuf *sb,
+				  const char **branch,
+				  const char *path)
+{
+	unsigned char sha1[20];
+
+	strbuf_reset(sb);
+	if (strbuf_read_file(sb, git_path("%s", path), 0) <= 0)
+		return;
+
+	while (sb->len && sb->buf[sb->len - 1] == '\n')
+		strbuf_setlen(sb, sb->len - 1);
+	if (!sb->len)
+		return;
+	if (!prefixcmp(sb->buf, "refs/heads/"))
+		*branch = sb->buf + strlen("refs/heads/");
+	else if (!prefixcmp(sb->buf, "refs/"))
+		*branch = sb->buf;
+	else if (!get_sha1_hex(sb->buf, sha1)) {
+		const char *abbrev;
+		abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
+		strbuf_reset(sb);
+		strbuf_addstr(sb, abbrev);
+		*branch = sb->buf;
+	} else if (!strcmp(sb->buf, "detached HEAD")) /* rebase */
+		;
+	else			/* bisect */
+		*branch = sb->buf;
+}
+
 static void wt_status_print_state(struct wt_status *s)
 {
 	const char *state_color = color(WT_STATUS_HEADER, s);
+	struct strbuf branch = STRBUF_INIT;
+	struct strbuf onto = STRBUF_INIT;
 	struct wt_status_state state;
 	struct stat st;
 
@@ -947,17 +1013,28 @@ static void wt_status_print_state(struct wt_status *s)
 				state.am_empty_patch = 1;
 		} else {
 			state.rebase_in_progress = 1;
+			read_and_strip_branch(&branch, &state.branch,
+					      "rebase-apply/head-name");
+			read_and_strip_branch(&onto, &state.onto,
+					      "rebase-apply/onto");
 		}
 	} else if (!stat(git_path("rebase-merge"), &st)) {
 		if (!stat(git_path("rebase-merge/interactive"), &st))
 			state.rebase_interactive_in_progress = 1;
 		else
 			state.rebase_in_progress = 1;
+		read_and_strip_branch(&branch, &state.branch,
+				      "rebase-merge/head-name");
+		read_and_strip_branch(&onto, &state.onto,
+				      "rebase-merge/onto");
 	} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
 		state.cherry_pick_in_progress = 1;
 	}
-	if (!stat(git_path("BISECT_LOG"), &st))
+	if (!stat(git_path("BISECT_LOG"), &st)) {
 		state.bisect_in_progress = 1;
+		read_and_strip_branch(&branch, &state.branch,
+				      "BISECT_START");
+	}
 
 	if (state.merge_in_progress)
 		show_merge_in_progress(s, &state, state_color);
@@ -969,6 +1046,8 @@ static void wt_status_print_state(struct wt_status *s)
 		show_cherry_pick_in_progress(s, &state, state_color);
 	if (state.bisect_in_progress)
 		show_bisect_in_progress(s, &state, state_color);
+	strbuf_release(&branch);
+	strbuf_release(&onto);
 }
 
 void wt_status_print(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index 236b41f..81e1dcf 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -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);
-- 
1.8.1.1.459.g5970e58

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] status: show branch name if possible in in-progress info
  2013-01-29 13:13     ` Matthieu Moy
@ 2013-01-29 16:18       ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2013-01-29 16:18 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Duy Nguyen, git

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> 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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] status: show the branch name if possible in in-progress info
  2013-01-29 14:58 ` [PATCH v2] status: show the " Nguyễn Thái Ngọc Duy
@ 2013-01-29 18:44   ` Jonathan Nieder
  2013-01-30  1:13     ` Duy Nguyen
  2013-02-03  5:53   ` [PATCH v3] " Nguyễn Thái Ngọc Duy
  1 sibling, 1 reply; 12+ messages in thread
From: Jonathan Nieder @ 2013-01-29 18:44 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Matthieu Moy

Hi Duy,

Nguyễn Thái Ngọc Duy wrote:

> --- a/t/t7512-status-help.sh
> +++ b/t/t7512-status-help.sh
> @@ -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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] status: show the branch name if possible in in-progress info
  2013-01-29 18:44   ` Jonathan Nieder
@ 2013-01-30  1:13     ` Duy Nguyen
  0 siblings, 0 replies; 12+ messages in thread
From: Duy Nguyen @ 2013-01-30  1:13 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Matthieu Moy

On Wed, Jan 30, 2013 at 1:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> -     # 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'\''.
>
> ?

That may be better. Yeah.

> 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
-- 
Duy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] status: show the branch name if possible in in-progress info
  2013-01-29 14:58 ` [PATCH v2] status: show the " Nguyễn Thái Ngọc Duy
  2013-01-29 18:44   ` Jonathan Nieder
@ 2013-02-03  5:53   ` Nguyễn Thái Ngọc Duy
  2013-02-05  6:38     ` Jonathan Nieder
  1 sibling, 1 reply; 12+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2013-02-03  5:53 UTC (permalink / raw)
  To: git
  Cc: Matthieu Moy, Jonathan Niedier, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 - 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(-)

diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index b3f6eb9..51ab894 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -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
diff --git a/wt-status.c b/wt-status.c
index d7cfe8f..983e2f4 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -872,7 +872,14 @@ static void show_rebase_in_progress(struct wt_status *s,
 	struct stat st;
 
 	if (has_unmerged(s)) {
-		status_printf_ln(s, color, _("You are currently rebasing."));
+		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 (advice_status_hints) {
 			status_printf_ln(s, color,
 				_("  (fix conflicts and then run \"git rebase --continue\")"));
@@ -882,17 +889,38 @@ 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)) {
-		status_printf_ln(s, color, _("You are currently rebasing."));
+		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 (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (all conflicts fixed: run \"git rebase --continue\")"));
 	} else if (split_commit_in_progress(s)) {
-		status_printf_ln(s, color, _("You are currently splitting a commit during a rebase."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently splitting a commit while rebasing branch '%s' on '%s'."),
+					 state->branch,
+					 state->onto);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently splitting a commit during a rebase."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (Once your working directory is clean, run \"git rebase --continue\")"));
 	} else {
-		status_printf_ln(s, color, _("You are currently editing a commit during a rebase."));
+		if (state->branch)
+			status_printf_ln(s, color,
+					 _("You are currently editing a commit while rebasing branch '%s' on '%s'."),
+					 state->branch,
+					 state->onto);
+		else
+			status_printf_ln(s, color,
+					 _("You are currently editing a commit during a rebase."));
 		if (advice_status_hints && !s->amend) {
 			status_printf_ln(s, color,
 				_("  (use \"git commit --amend\" to amend the current commit)"));
@@ -923,16 +951,57 @@ 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."));
+	if (state->branch)
+		status_printf_ln(s, color,
+				 _("You are currently bisecting branch '%s'."),
+				 state->branch);
+	else
+		status_printf_ln(s, color,
+				 _("You are currently bisecting."));
 	if (advice_status_hints)
 		status_printf_ln(s, color,
 			_("  (use \"git bisect reset\" to get back to the original branch)"));
 	wt_status_print_trailer(s);
 }
 
+/*
+ * Extract branch information from rebase/bisect
+ */
+static void read_and_strip_branch(struct strbuf *sb,
+				  const char **branch,
+				  const char *path)
+{
+	unsigned char sha1[20];
+
+	strbuf_reset(sb);
+	if (strbuf_read_file(sb, git_path("%s", path), 0) <= 0)
+		return;
+
+	while (sb->len && sb->buf[sb->len - 1] == '\n')
+		strbuf_setlen(sb, sb->len - 1);
+	if (!sb->len)
+		return;
+	if (!prefixcmp(sb->buf, "refs/heads/"))
+		*branch = sb->buf + strlen("refs/heads/");
+	else if (!prefixcmp(sb->buf, "refs/"))
+		*branch = sb->buf;
+	else if (!get_sha1_hex(sb->buf, sha1)) {
+		const char *abbrev;
+		abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
+		strbuf_reset(sb);
+		strbuf_addstr(sb, abbrev);
+		*branch = sb->buf;
+	} else if (!strcmp(sb->buf, "detached HEAD")) /* rebase */
+		;
+	else			/* bisect */
+		*branch = sb->buf;
+}
+
 static void wt_status_print_state(struct wt_status *s)
 {
 	const char *state_color = color(WT_STATUS_HEADER, s);
+	struct strbuf branch = STRBUF_INIT;
+	struct strbuf onto = STRBUF_INIT;
 	struct wt_status_state state;
 	struct stat st;
 
@@ -947,17 +1016,28 @@ static void wt_status_print_state(struct wt_status *s)
 				state.am_empty_patch = 1;
 		} else {
 			state.rebase_in_progress = 1;
+			read_and_strip_branch(&branch, &state.branch,
+					      "rebase-apply/head-name");
+			read_and_strip_branch(&onto, &state.onto,
+					      "rebase-apply/onto");
 		}
 	} else if (!stat(git_path("rebase-merge"), &st)) {
 		if (!stat(git_path("rebase-merge/interactive"), &st))
 			state.rebase_interactive_in_progress = 1;
 		else
 			state.rebase_in_progress = 1;
+		read_and_strip_branch(&branch, &state.branch,
+				      "rebase-merge/head-name");
+		read_and_strip_branch(&onto, &state.onto,
+				      "rebase-merge/onto");
 	} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
 		state.cherry_pick_in_progress = 1;
 	}
-	if (!stat(git_path("BISECT_LOG"), &st))
+	if (!stat(git_path("BISECT_LOG"), &st)) {
 		state.bisect_in_progress = 1;
+		read_and_strip_branch(&branch, &state.branch,
+				      "BISECT_START");
+	}
 
 	if (state.merge_in_progress)
 		show_merge_in_progress(s, &state, state_color);
@@ -969,6 +1049,8 @@ static void wt_status_print_state(struct wt_status *s)
 		show_cherry_pick_in_progress(s, &state, state_color);
 	if (state.bisect_in_progress)
 		show_bisect_in_progress(s, &state, state_color);
+	strbuf_release(&branch);
+	strbuf_release(&onto);
 }
 
 void wt_status_print(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index 236b41f..81e1dcf 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -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);
-- 
1.8.1.1.459.g5970e58

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] status: show the branch name if possible in in-progress info
  2013-02-03  5:53   ` [PATCH v3] " Nguyễn Thái Ngọc Duy
@ 2013-02-05  6:38     ` Jonathan Nieder
  2013-02-05 12:20       ` Duy Nguyen
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Nieder @ 2013-02-05  6:38 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Matthieu Moy, Junio C Hamano

Nguyễn Thái Ngọc Duy wrote:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>

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: <...>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] status: show the branch name if possible in in-progress info
  2013-02-05  6:38     ` Jonathan Nieder
@ 2013-02-05 12:20       ` Duy Nguyen
  2013-02-05 16:28         ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Duy Nguyen @ 2013-02-05 12:20 UTC (permalink / raw)
  To: Jonathan Nieder, Junio C Hamano; +Cc: git, Matthieu Moy

On Tue, Feb 5, 2013 at 1:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> 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: <...>

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] status: show the branch name if possible in in-progress info
  2013-02-05 12:20       ` Duy Nguyen
@ 2013-02-05 16:28         ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2013-02-05 16:28 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Jonathan Nieder, git, Matthieu Moy

Duy Nguyen <pclouds@gmail.com> writes:

> On Tue, Feb 5, 2013 at 1:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> 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: <...>
>
> 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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-02-05 16:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-29 12:10 [PATCH] status: show branch name if possible in in-progress info Nguyễn Thái Ngọc Duy
2013-01-29 12:31 ` Matthieu Moy
2013-01-29 12:56   ` Duy Nguyen
2013-01-29 13:13     ` Matthieu Moy
2013-01-29 16:18       ` Junio C Hamano
2013-01-29 14:58 ` [PATCH v2] status: show the " Nguyễn Thái Ngọc Duy
2013-01-29 18:44   ` Jonathan Nieder
2013-01-30  1:13     ` Duy Nguyen
2013-02-03  5:53   ` [PATCH v3] " Nguyễn Thái Ngọc Duy
2013-02-05  6:38     ` Jonathan Nieder
2013-02-05 12:20       ` Duy Nguyen
2013-02-05 16:28         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).