{"thread":{"id":"32768","subject":"[PATCH] status: show branch name if possible in in-progress info","startedAt":"2013-01-29T12:10:50Z","lastAt":"2013-02-05T16:28:42Z","messageCount":12,"participants":["Nguyễn Thái Ngọc Duy","Matthieu Moy","Duy Nguyen","Junio C Hamano","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"208181","messageId":"1359461450-24456-1-git-send-email-pclouds@gmail.com","threadId":"32768","inReplyTo":null,"subject":"[PATCH] status: show branch name if possible in in-progress info","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-01-29T12:10:50Z","receivedAt":"2013-01-29T12:10:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Seems like a good thing to do.\n\n t/t7512-status-help.sh | 36 +++++++++++++++----------------\n wt-status.c            | 58 ++++++++++++++++++++++++++++++++++++++++++--------\n wt-status.h            |  1 +\n 3 files changed, 68 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex b3f6eb9..096ba6f 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing '\\''rebase_conflicts'\\''.\n \t#   (fix conflicts and then run \"git rebase --continue\")\n \t#   (use \"git rebase --skip\" to skip this patch)\n \t#   (use \"git rebase --abort\" to check out the original branch)\n@@ -102,7 +102,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '\n \tgit add main.txt &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing '\\''rebase_conflicts'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n \t# Changes to be committed:\n@@ -133,7 +133,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing '\\''rebase_i_conflicts_second'\\''.\n \t#   (fix conflicts and then run \"git rebase --continue\")\n \t#   (use \"git rebase --skip\" to skip this patch)\n \t#   (use \"git rebase --abort\" to check out the original branch)\n@@ -158,7 +158,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '\n \tgit add main.txt &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing '\\''rebase_i_conflicts_second'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n \t# Changes to be committed:\n@@ -185,7 +185,7 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \tgit rebase -i HEAD~2 &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''rebase_i_edit'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -210,7 +210,7 @@ test_expect_success 'status when splitting a commit' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing '\\''split_commit'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -240,7 +240,7 @@ test_expect_success 'status after editing the last commit with --amend during a\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''amend_last'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -269,7 +269,7 @@ test_expect_success 'status: (continue first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''several_edits'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -290,7 +290,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing '\\''several_edits'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -316,7 +316,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''several_edits'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -337,7 +337,7 @@ test_expect_success 'status: (amend first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''several_edits'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -359,7 +359,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing '\\''several_edits'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -386,7 +386,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tgit commit --amend -m \"d\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''several_edits'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -409,7 +409,7 @@ test_expect_success 'status: (split first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''several_edits'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -433,7 +433,7 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing '\\''several_edits'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -462,7 +462,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tgit commit --amend -m \"h\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing '\\''several_edits'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -558,7 +558,7 @@ test_expect_success 'status when bisecting' '\n \tgit bisect good one_bisect &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently bisecting.\n+\t# You are currently bisecting '\\''bisect'\\''.\n \t#   (use \"git bisect reset\" to get back to the original branch)\n \t#\n \tnothing to commit (use -u to show untracked files)\n@@ -580,7 +580,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing '\\''statushints_disabled'\\''.\n \t#\n \t# Unmerged paths:\n \t#\tboth modified:      main.txt\ndiff --git a/wt-status.c b/wt-status.c\nindex d7cfe8f..cc7e2d7 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -872,7 +872,13 @@ static void show_rebase_in_progress(struct wt_status *s,\n \tstruct stat st;\n \n \tif (has_unmerged(s)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing '%s'.\"),\n+\t\t\t\t\t state->branch);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n@@ -882,17 +888,35 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n \t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing '%s'.\"),\n+\t\t\t\t\t state->branch);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n \t} else if (split_commit_in_progress(s)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently splitting a commit during a rebase.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently splitting a commit while rebasing '%s'.\"),\n+\t\t\t\t\t state->branch);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently splitting a commit during a rebase.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (Once your working directory is clean, run \\\"git rebase --continue\\\")\"));\n \t} else {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently editing a commit during a rebase.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently editing a commit while rebasing '%s'.\"),\n+\t\t\t\t\t state->branch);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently editing a commit during a rebase.\"));\n \t\tif (advice_status_hints && !s->amend) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git commit --amend\\\" to amend the current commit)\"));\n@@ -923,7 +947,7 @@ static void show_bisect_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tstatus_printf_ln(s, color, _(\"You are currently bisecting.\"));\n+\tstatus_printf_ln(s, color, _(\"You are currently bisecting '%s'.\"), state->branch);\n \tif (advice_status_hints)\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git bisect reset\\\" to get back to the original branch)\"));\n@@ -935,6 +959,7 @@ static void wt_status_print_state(struct wt_status *s)\n \tconst char *state_color = color(WT_STATUS_HEADER, s);\n \tstruct wt_status_state state;\n \tstruct stat st;\n+\tstruct strbuf sb = STRBUF_INIT;\n \n \tmemset(&state, 0, sizeof(state));\n \n@@ -947,28 +972,43 @@ static void wt_status_print_state(struct wt_status *s)\n \t\t\t\tstate.am_empty_patch = 1;\n \t\t} else {\n \t\t\tstate.rebase_in_progress = 1;\n+\t\t\tstrbuf_read_file(&sb, git_path(\"rebase-apply/head-name\"), 0);\n \t\t}\n \t} else if (!stat(git_path(\"rebase-merge\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-merge/interactive\"), &st))\n \t\t\tstate.rebase_interactive_in_progress = 1;\n \t\telse\n \t\t\tstate.rebase_in_progress = 1;\n+\t\tstrbuf_read_file(&sb, git_path(\"rebase-merge/head-name\"), 0);\n \t} else if (!stat(git_path(\"CHERRY_PICK_HEAD\"), &st)) {\n \t\tstate.cherry_pick_in_progress = 1;\n \t}\n-\tif (!stat(git_path(\"BISECT_LOG\"), &st))\n+\tif (!stat(git_path(\"BISECT_LOG\"), &st)) {\n+\t\tstrbuf_read_file(&sb, git_path(\"BISECT_START\"), 0);\n \t\tstate.bisect_in_progress = 1;\n+\t}\n \n \tif (state.merge_in_progress)\n \t\tshow_merge_in_progress(s, &state, state_color);\n \telse if (state.am_in_progress)\n \t\tshow_am_in_progress(s, &state, state_color);\n-\telse if (state.rebase_in_progress || state.rebase_interactive_in_progress)\n+\telse if (state.rebase_in_progress || state.rebase_interactive_in_progress) {\n+\t\twhile (sb.len && sb.buf[sb.len - 1] == '\\n')\n+\t\t\tstrbuf_setlen(&sb, sb.len - 1);\n+\t\tif (!prefixcmp(sb.buf, \"refs/heads/\"))\n+\t\t\tstate.branch = sb.buf + strlen(\"refs/heads/\");\n+\t\telse if (!prefixcmp(sb.buf, \"refs/\"))\n+\t\t\tstate.branch = sb.buf;\n \t\tshow_rebase_in_progress(s, &state, state_color);\n-\telse if (state.cherry_pick_in_progress)\n+\t} else if (state.cherry_pick_in_progress)\n \t\tshow_cherry_pick_in_progress(s, &state, state_color);\n-\tif (state.bisect_in_progress)\n+\tif (state.bisect_in_progress) {\n+\t\twhile (sb.len && sb.buf[sb.len - 1] == '\\n')\n+\t\t\tstrbuf_setlen(&sb, sb.len - 1);\n+\t\tstate.branch = sb.buf;\n \t\tshow_bisect_in_progress(s, &state, state_color);\n+\t}\n+\tstrbuf_release(&sb);\n }\n \n void wt_status_print(struct wt_status *s)\ndiff --git a/wt-status.h b/wt-status.h\nindex 236b41f..c5eae29 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -79,6 +79,7 @@ struct wt_status_state {\n \tint rebase_interactive_in_progress;\n \tint cherry_pick_in_progress;\n \tint bisect_in_progress;\n+\tconst char *branch;\n };\n \n void wt_status_prepare(struct wt_status *s);\n-- \n1.8.1.1.459.g5970e58\n"},{"id":"208184","messageId":"vpqy5fcrwzq.fsf@grenoble-inp.fr","threadId":"32768","inReplyTo":"1359461450-24456-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] status: show branch name if possible in in-progress info","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-01-29T12:31:53Z","receivedAt":"2013-01-29T12:31:53Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"I like the idea.\n\nNguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\n> index b3f6eb9..096ba6f 100755\n> --- a/t/t7512-status-help.sh\n> +++ b/t/t7512-status-help.sh\n> @@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n>  \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n>  \tcat >expected <<-\\EOF &&\n>  \t# Not currently on any branch.\n> -\t# You are currently rebasing.\n> +\t# You are currently rebasing '\\''rebase_conflicts'\\''.\n\nPerhaps \"rebasing *branch* 'rebase_conflicts'\"\n\nOr even \"rebasing branch 'rebase_conflicts' on <sha1sum>\"\n\n?\n\n> @@ -923,7 +947,7 @@ static void show_bisect_in_progress(struct wt_status *s,\n>  \t\t\t\tstruct wt_status_state *state,\n>  \t\t\t\tconst char *color)\n>  {\n> -\tstatus_printf_ln(s, color, _(\"You are currently bisecting.\"));\n> +\tstatus_printf_ln(s, color, _(\"You are currently bisecting '%s'.\"), state->branch);\n>  \tif (advice_status_hints)\n>  \t\tstatus_printf_ln(s, color,\n>  \t\t\t_(\"  (use \\\"git bisect reset\\\" to get back to the original branch)\"));\n\nIn the \"rebase\" case, you test state->branch for null-ness. Don't you\nneed the same test here? (What happens if you start a bisect from a\ndetached HEAD state?)\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"208185","messageId":"CACsJy8DLdG9O+HaWS8u4n+imdaSZe=GrbYbPOhcMsYMWDq9NZw@mail.gmail.com","threadId":"32768","inReplyTo":"vpqy5fcrwzq.fsf@grenoble-inp.fr","subject":"Re: [PATCH] status: show branch name if possible in in-progress info","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-01-29T12:56:21Z","receivedAt":"2013-01-29T12:56:21Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jan 29, 2013 at 7:31 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> I like the idea.\n>\n> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n>\n>> diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\n>> index b3f6eb9..096ba6f 100755\n>> --- a/t/t7512-status-help.sh\n>> +++ b/t/t7512-status-help.sh\n>> @@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n>>       test_must_fail git rebase HEAD^ --onto HEAD^^ &&\n>>       cat >expected <<-\\EOF &&\n>>       # Not currently on any branch.\n>> -     # You are currently rebasing.\n>> +     # You are currently rebasing '\\''rebase_conflicts'\\''.\n>\n> Perhaps \"rebasing *branch* 'rebase_conflicts'\"\n\nLooks good. One minor thing, if the ref happens to be\nrefs/somewhere-not-in-heads, should we still say \"rebasing branch\n'refs/...'\" or just \"rebasing 'refs/...'\", or something else?\n\n>\n> Or even \"rebasing branch 'rebase_conflicts' on <sha1sum>\"\n\n<sha1sum> being SHA-1 of HEAD? Why would you need it? In short\nversion, not full SHA-1?\n\n> ?\n>\n>> @@ -923,7 +947,7 @@ static void show_bisect_in_progress(struct wt_status *s,\n>>                               struct wt_status_state *state,\n>>                               const char *color)\n>>  {\n>> -     status_printf_ln(s, color, _(\"You are currently bisecting.\"));\n>> +     status_printf_ln(s, color, _(\"You are currently bisecting '%s'.\"), state->branch);\n>>       if (advice_status_hints)\n>>               status_printf_ln(s, color,\n>>                       _(\"  (use \\\"git bisect reset\\\" to get back to the original branch)\"));\n>\n> In the \"rebase\" case, you test state->branch for null-ness. Don't you\n> need the same test here? (What happens if you start a bisect from a\n> detached HEAD state?)\n\nI did read git-bisect.sh. I did not think it allowed bisecting on\ndetached HEAD. A simple test just told me otherwise. Will update.\n-- \nDuy\n"},{"id":"208186","messageId":"vpqd2worv23.fsf@grenoble-inp.fr","threadId":"32768","inReplyTo":"CACsJy8DLdG9O+HaWS8u4n+imdaSZe=GrbYbPOhcMsYMWDq9NZw@mail.gmail.com","subject":"Re: [PATCH] status: show branch name if possible in in-progress info","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-01-29T13:13:40Z","receivedAt":"2013-01-29T13:13:40Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Tue, Jan 29, 2013 at 7:31 PM, Matthieu Moy\n> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>> I like the idea.\n>>\n>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n>>\n>>> diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\n>>> index b3f6eb9..096ba6f 100755\n>>> --- a/t/t7512-status-help.sh\n>>> +++ b/t/t7512-status-help.sh\n>>> @@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n>>>       test_must_fail git rebase HEAD^ --onto HEAD^^ &&\n>>>       cat >expected <<-\\EOF &&\n>>>       # Not currently on any branch.\n>>> -     # You are currently rebasing.\n>>> +     # You are currently rebasing '\\''rebase_conflicts'\\''.\n>>\n>> Perhaps \"rebasing *branch* 'rebase_conflicts'\"\n>\n> Looks good. One minor thing, if the ref happens to be\n> refs/somewhere-not-in-heads, should we still say \"rebasing branch\n> 'refs/...'\" or just \"rebasing 'refs/...'\", or something else?\n\nI think this should not happen, since HEAD can either point to a branch\nor directly to a sha1 in normal conditions. But it doesn't harm to be\ndefensive, in case ...\n\n>> Or even \"rebasing branch 'rebase_conflicts' on <sha1sum>\"\n>\n> <sha1sum> being SHA-1 of HEAD?\n\nNot HEAD, but .git/rebase-merge/onto, i.e. the target of the rebase.\nIdeally, I would have loved to see \"rebasing master on origin/master\",\nbut I do not think the target ref name is stored during rebase.\n\n> Why would you need it?\n\nThe typical use-case is starting a rebase, do something else, come back\nthe day after and wonder wft. Which branch is being rebased is probably\nthe most useful, but the target may help too. But I can live\nwithout ;-).\n\n> In short version, not full SHA-1?\n\nIf you add it, the short one (long version would make overly long line\nwith limited use).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"208187","messageId":"1359471493-32531-1-git-send-email-pclouds@gmail.com","threadId":"32768","inReplyTo":"1359461450-24456-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2] status: show the branch name if possible in in-progress info","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-01-29T14:58:13Z","receivedAt":"2013-01-29T14:58:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n - fix bisecting on detached HEAD\n - show onto sha-1 for rebase\n\n t/t7512-status-help.sh | 36 ++++++++++----------\n wt-status.c            | 91 ++++++++++++++++++++++++++++++++++++++++++++++----\n wt-status.h            |  2 ++\n 3 files changed, 105 insertions(+), 24 deletions(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex b3f6eb9..67ece6b 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''000106f'\\''.\n \t#   (fix conflicts and then run \"git rebase --continue\")\n \t#   (use \"git rebase --skip\" to skip this patch)\n \t#   (use \"git rebase --abort\" to check out the original branch)\n@@ -102,7 +102,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '\n \tgit add main.txt &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''000106f'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n \t# Changes to be committed:\n@@ -133,7 +133,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''e0164e4'\\''.\n \t#   (fix conflicts and then run \"git rebase --continue\")\n \t#   (use \"git rebase --skip\" to skip this patch)\n \t#   (use \"git rebase --abort\" to check out the original branch)\n@@ -158,7 +158,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '\n \tgit add main.txt &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''e0164e4'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n \t# Changes to be committed:\n@@ -185,7 +185,7 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \tgit rebase -i HEAD~2 &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''rebase_i_edit'\\'' on '\\''f90e540'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -210,7 +210,7 @@ test_expect_success 'status when splitting a commit' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''split_commit'\\'' on '\\''19b175e'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -240,7 +240,7 @@ test_expect_success 'status after editing the last commit with --amend during a\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''amend_last'\\'' on '\\''dd030b9'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -269,7 +269,7 @@ test_expect_success 'status: (continue first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -290,7 +290,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -316,7 +316,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -337,7 +337,7 @@ test_expect_success 'status: (amend first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -359,7 +359,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -386,7 +386,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tgit commit --amend -m \"d\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -409,7 +409,7 @@ test_expect_success 'status: (split first edit) second edit' '\n \tgit rebase --continue &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -433,7 +433,7 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tgit reset HEAD^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -462,7 +462,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tgit commit --amend -m \"h\" &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''eb16a7e'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -558,7 +558,7 @@ test_expect_success 'status when bisecting' '\n \tgit bisect good one_bisect &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently bisecting.\n+\t# You are currently bisecting branch '\\''bisect'\\''.\n \t#   (use \"git bisect reset\" to get back to the original branch)\n \t#\n \tnothing to commit (use -u to show untracked files)\n@@ -580,7 +580,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''statushints_disabled'\\'' on '\\''1d51a61'\\''.\n \t#\n \t# Unmerged paths:\n \t#\tboth modified:      main.txt\ndiff --git a/wt-status.c b/wt-status.c\nindex d7cfe8f..42fafd0 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -872,7 +872,14 @@ static void show_rebase_in_progress(struct wt_status *s,\n \tstruct stat st;\n \n \tif (has_unmerged(s)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n@@ -882,17 +889,38 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n \t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n \t} else if (split_commit_in_progress(s)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently splitting a commit during a rebase.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently splitting a commit while rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently splitting a commit during a rebase.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (Once your working directory is clean, run \\\"git rebase --continue\\\")\"));\n \t} else {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently editing a commit during a rebase.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently editing a commit while rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently editing a commit during a rebase.\"));\n \t\tif (advice_status_hints && !s->amend) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git commit --amend\\\" to amend the current commit)\"));\n@@ -923,16 +951,54 @@ static void show_bisect_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tstatus_printf_ln(s, color, _(\"You are currently bisecting.\"));\n+\tif (state->branch)\n+\t\tstatus_printf_ln(s, color,\n+\t\t\t\t _(\"You are currently bisecting branch '%s'.\"),\n+\t\t\t\t state->branch);\n+\telse\n+\t\tstatus_printf_ln(s, color,\n+\t\t\t\t _(\"You are currently bisecting.\"));\n \tif (advice_status_hints)\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git bisect reset\\\" to get back to the original branch)\"));\n \twt_status_print_trailer(s);\n }\n \n+static void read_and_strip_branch(struct strbuf *sb,\n+\t\t\t\t  const char **branch,\n+\t\t\t\t  const char *path)\n+{\n+\tunsigned char sha1[20];\n+\n+\tstrbuf_reset(sb);\n+\tif (strbuf_read_file(sb, git_path(\"%s\", path), 0) <= 0)\n+\t\treturn;\n+\n+\twhile (sb->len && sb->buf[sb->len - 1] == '\\n')\n+\t\tstrbuf_setlen(sb, sb->len - 1);\n+\tif (!sb->len)\n+\t\treturn;\n+\tif (!prefixcmp(sb->buf, \"refs/heads/\"))\n+\t\t*branch = sb->buf + strlen(\"refs/heads/\");\n+\telse if (!prefixcmp(sb->buf, \"refs/\"))\n+\t\t*branch = sb->buf;\n+\telse if (!get_sha1_hex(sb->buf, sha1)) {\n+\t\tconst char *abbrev;\n+\t\tabbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);\n+\t\tstrbuf_reset(sb);\n+\t\tstrbuf_addstr(sb, abbrev);\n+\t\t*branch = sb->buf;\n+\t} else if (!strcmp(sb->buf, \"detached HEAD\")) /* rebase */\n+\t\t;\n+\telse\t\t\t/* bisect */\n+\t\t*branch = sb->buf;\n+}\n+\n static void wt_status_print_state(struct wt_status *s)\n {\n \tconst char *state_color = color(WT_STATUS_HEADER, s);\n+\tstruct strbuf branch = STRBUF_INIT;\n+\tstruct strbuf onto = STRBUF_INIT;\n \tstruct wt_status_state state;\n \tstruct stat st;\n \n@@ -947,17 +1013,28 @@ static void wt_status_print_state(struct wt_status *s)\n \t\t\t\tstate.am_empty_patch = 1;\n \t\t} else {\n \t\t\tstate.rebase_in_progress = 1;\n+\t\t\tread_and_strip_branch(&branch, &state.branch,\n+\t\t\t\t\t      \"rebase-apply/head-name\");\n+\t\t\tread_and_strip_branch(&onto, &state.onto,\n+\t\t\t\t\t      \"rebase-apply/onto\");\n \t\t}\n \t} else if (!stat(git_path(\"rebase-merge\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-merge/interactive\"), &st))\n \t\t\tstate.rebase_interactive_in_progress = 1;\n \t\telse\n \t\t\tstate.rebase_in_progress = 1;\n+\t\tread_and_strip_branch(&branch, &state.branch,\n+\t\t\t\t      \"rebase-merge/head-name\");\n+\t\tread_and_strip_branch(&onto, &state.onto,\n+\t\t\t\t      \"rebase-merge/onto\");\n \t} else if (!stat(git_path(\"CHERRY_PICK_HEAD\"), &st)) {\n \t\tstate.cherry_pick_in_progress = 1;\n \t}\n-\tif (!stat(git_path(\"BISECT_LOG\"), &st))\n+\tif (!stat(git_path(\"BISECT_LOG\"), &st)) {\n \t\tstate.bisect_in_progress = 1;\n+\t\tread_and_strip_branch(&branch, &state.branch,\n+\t\t\t\t      \"BISECT_START\");\n+\t}\n \n \tif (state.merge_in_progress)\n \t\tshow_merge_in_progress(s, &state, state_color);\n@@ -969,6 +1046,8 @@ static void wt_status_print_state(struct wt_status *s)\n \t\tshow_cherry_pick_in_progress(s, &state, state_color);\n \tif (state.bisect_in_progress)\n \t\tshow_bisect_in_progress(s, &state, state_color);\n+\tstrbuf_release(&branch);\n+\tstrbuf_release(&onto);\n }\n \n void wt_status_print(struct wt_status *s)\ndiff --git a/wt-status.h b/wt-status.h\nindex 236b41f..81e1dcf 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -79,6 +79,8 @@ struct wt_status_state {\n \tint rebase_interactive_in_progress;\n \tint cherry_pick_in_progress;\n \tint bisect_in_progress;\n+\tconst char *branch;\n+\tconst char *onto;\n };\n \n void wt_status_prepare(struct wt_status *s);\n-- \n1.8.1.1.459.g5970e58\n"},{"id":"208193","messageId":"7vobg8rmi4.fsf@alter.siamese.dyndns.org","threadId":"32768","inReplyTo":"vpqd2worv23.fsf@grenoble-inp.fr","subject":"Re: [PATCH] status: show branch name if possible in in-progress info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-29T16:18:27Z","receivedAt":"2013-01-29T16:18:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Not HEAD, but .git/rebase-merge/onto, i.e. the target of the rebase.\n> Ideally, I would have loved to see \"rebasing master on origin/master\",\n> but I do not think the target ref name is stored during rebase.\n\nPerhaps do it with --format=%s then.  It often is useless to know\nonly the commit object name (or the branch name for that matter, as\nyou wouldn't know what exact commit the branch tip happens to have)\nyou are rebasing onto.\n"},{"id":"208204","messageId":"20130129184435.GA18266@google.com","threadId":"32768","inReplyTo":"1359471493-32531-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2] status: show the branch name if possible in in-progress info","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-01-29T18:44:35Z","receivedAt":"2013-01-29T18:44:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Duy,\n\nNguyễn Thái Ngọc Duy wrote:\n\n> --- a/t/t7512-status-help.sh\n> +++ b/t/t7512-status-help.sh\n> @@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n>  \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n>  \tcat >expected <<-\\EOF &&\n>  \t# Not currently on any branch.\n> -\t# You are currently rebasing.\n> +\t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''000106f'\\''.\n\nSHA1-in-tests radar blinking.\n\nWould it be possible to compute the expected output, as in\n\n\tdest=$(git rev-parse --short HEAD^^)\n\tcat >expected <<-EOF &&\n\t# Not currently on any branch.\n\t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''$dest'\\''.\n\n?\n\nI'm not sure what to think about the actual change itself yet.  Can you\ngive an example of when you felt the need for this, so it can be\nincluded in the commit message or documentation?\n\nThanks.\nJonathan\n"},{"id":"208234","messageId":"CACsJy8ByU8jNFHi2wDyJG+Qfzg7r8R3=RwOqxo3o5UCqjRyy+g@mail.gmail.com","threadId":"32768","inReplyTo":"20130129184435.GA18266@google.com","subject":"Re: [PATCH v2] status: show the branch name if possible in in-progress info","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-01-30T01:13:49Z","receivedAt":"2013-01-30T01:13:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Jan 30, 2013 at 1:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> -     # You are currently rebasing.\n>> +     # You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''000106f'\\''.\n>\n> SHA1-in-tests radar blinking.\n>\n> Would it be possible to compute the expected output, as in\n>\n>         dest=$(git rev-parse --short HEAD^^)\n>         cat >expected <<-EOF &&\n>         # Not currently on any branch.\n>         # You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''$dest'\\''.\n>\n> ?\n\nThat may be better. Yeah.\n\n> I'm not sure what to think about the actual change itself yet.  Can you\n> give an example of when you felt the need for this, so it can be\n> included in the commit message or documentation?\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/214932/focus=214937\n-- \nDuy\n"},{"id":"208534","messageId":"1359870807-22817-1-git-send-email-pclouds@gmail.com","threadId":"32768","inReplyTo":"1359471493-32531-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3] status: show the branch name if possible in in-progress info","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-02-03T05:53:27Z","receivedAt":"2013-02-03T05:53:27Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n - avoid hardcoding SHA-1 in t7512\n - I did not act on Junio's --format=%s idea because frankly I don't\n   care much about the \"on 'xxx'\" part. It was Matthieu's idea and he\n   did not make any comments on --format=%s\n\n t/t7512-status-help.sh | 87 +++++++++++++++++++++++++++-------------------\n wt-status.c            | 94 ++++++++++++++++++++++++++++++++++++++++++++++----\n wt-status.h            |  2 ++\n 3 files changed, 142 insertions(+), 41 deletions(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex b3f6eb9..51ab894 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -73,10 +73,11 @@ test_expect_success 'prepare for rebase conflicts' '\n \n test_expect_success 'status when rebase in progress before resolving conflicts' '\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD^^) &&\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''$ONTO'\\''.\n \t#   (fix conflicts and then run \"git rebase --continue\")\n \t#   (use \"git rebase --skip\" to skip this patch)\n \t#   (use \"git rebase --abort\" to check out the original branch)\n@@ -97,12 +98,13 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n test_expect_success 'status when rebase in progress before rebase --continue' '\n \tgit reset --hard rebase_conflicts &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD^^) &&\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \techo three >main.txt &&\n \tgit add main.txt &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''$ONTO'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n \t# Changes to be committed:\n@@ -130,10 +132,11 @@ test_expect_success 'prepare for rebase_i_conflicts' '\n \n test_expect_success 'status during rebase -i when conflicts unresolved' '\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short rebase_i_conflicts) &&\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n \t#   (fix conflicts and then run \"git rebase --continue\")\n \t#   (use \"git rebase --skip\" to skip this patch)\n \t#   (use \"git rebase --abort\" to check out the original branch)\n@@ -154,11 +157,12 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '\n test_expect_success 'status during rebase -i after resolving conflicts' '\n \tgit reset --hard rebase_i_conflicts_second &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short rebase_i_conflicts) &&\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tgit add main.txt &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''rebase_i_conflicts_second'\\'' on '\\''$ONTO'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n \t# Changes to be committed:\n@@ -182,10 +186,11 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \tFAKE_LINES=\"1 edit 2\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~2) &&\n \tgit rebase -i HEAD~2 &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''rebase_i_edit'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -206,11 +211,12 @@ test_expect_success 'status when splitting a commit' '\n \tFAKE_LINES=\"1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''split_commit'\\'' on '\\''$ONTO'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -236,11 +242,12 @@ test_expect_success 'status after editing the last commit with --amend during a\n \tFAKE_LINES=\"1 2 edit 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"foo\" &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''amend_last'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -265,11 +272,12 @@ test_expect_success 'status: (continue first edit) second edit' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -285,12 +293,13 @@ test_expect_success 'status: (continue first edit) second edit and split' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -311,12 +320,13 @@ test_expect_success 'status: (continue first edit) second edit and amend' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tgit commit --amend -m \"foo\" &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -332,12 +342,13 @@ test_expect_success 'status: (amend first edit) second edit' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"a\" &&\n \tgit rebase --continue &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -353,13 +364,14 @@ test_expect_success 'status: (amend first edit) second edit and split' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"b\" &&\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -380,13 +392,14 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"c\" &&\n \tgit rebase --continue &&\n \tgit commit --amend -m \"d\" &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -402,14 +415,15 @@ test_expect_success 'status: (split first edit) second edit' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n \tgit add main.txt &&\n \tgit commit -m \"e\" &&\n \tgit rebase --continue &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -425,15 +439,16 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n \tgit add main.txt &&\n \tgit commit --amend -m \"f\" &&\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently splitting a commit during a rebase.\n+\t# You are currently splitting a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (Once your working directory is clean, run \"git rebase --continue\")\n \t#\n \t# Changes not staged for commit:\n@@ -454,15 +469,16 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tFAKE_LINES=\"edit 1 edit 2 3\" &&\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n \tgit add main.txt &&\n \tgit commit --amend -m \"g\" &&\n \tgit rebase --continue &&\n \tgit commit --amend -m \"h\" &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently editing a commit during a rebase.\n+\t# You are currently editing a commit while rebasing branch '\\''several_edits'\\'' on '\\''$ONTO'\\''.\n \t#   (use \"git commit --amend\" to amend the current commit)\n \t#   (use \"git rebase --continue\" once you are satisfied with your changes)\n \t#\n@@ -558,7 +574,7 @@ test_expect_success 'status when bisecting' '\n \tgit bisect good one_bisect &&\n \tcat >expected <<-\\EOF &&\n \t# Not currently on any branch.\n-\t# You are currently bisecting.\n+\t# You are currently bisecting branch '\\''bisect'\\''.\n \t#   (use \"git bisect reset\" to get back to the original branch)\n \t#\n \tnothing to commit (use -u to show untracked files)\n@@ -577,10 +593,11 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '\n \ttest_commit two_statushints main.txt two &&\n \ttest_commit three_statushints main.txt three &&\n \ttest_when_finished \"git rebase --abort\" &&\n+\tONTO=$(git rev-parse --short HEAD^^) &&\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n-\tcat >expected <<-\\EOF &&\n+\tcat >expected <<-EOF &&\n \t# Not currently on any branch.\n-\t# You are currently rebasing.\n+\t# You are currently rebasing branch '\\''statushints_disabled'\\'' on '\\''$ONTO'\\''.\n \t#\n \t# Unmerged paths:\n \t#\tboth modified:      main.txt\ndiff --git a/wt-status.c b/wt-status.c\nindex d7cfe8f..983e2f4 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -872,7 +872,14 @@ static void show_rebase_in_progress(struct wt_status *s,\n \tstruct stat st;\n \n \tif (has_unmerged(s)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (fix conflicts and then run \\\"git rebase --continue\\\")\"));\n@@ -882,17 +889,38 @@ static void show_rebase_in_progress(struct wt_status *s,\n \t\t\t\t_(\"  (use \\\"git rebase --abort\\\" to check out the original branch)\"));\n \t\t}\n \t} else if (state->rebase_in_progress || !stat(git_path(\"MERGE_MSG\"), &st)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently rebasing.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently rebasing.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (all conflicts fixed: run \\\"git rebase --continue\\\")\"));\n \t} else if (split_commit_in_progress(s)) {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently splitting a commit during a rebase.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently splitting a commit while rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently splitting a commit during a rebase.\"));\n \t\tif (advice_status_hints)\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (Once your working directory is clean, run \\\"git rebase --continue\\\")\"));\n \t} else {\n-\t\tstatus_printf_ln(s, color, _(\"You are currently editing a commit during a rebase.\"));\n+\t\tif (state->branch)\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently editing a commit while rebasing branch '%s' on '%s'.\"),\n+\t\t\t\t\t state->branch,\n+\t\t\t\t\t state->onto);\n+\t\telse\n+\t\t\tstatus_printf_ln(s, color,\n+\t\t\t\t\t _(\"You are currently editing a commit during a rebase.\"));\n \t\tif (advice_status_hints && !s->amend) {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\t_(\"  (use \\\"git commit --amend\\\" to amend the current commit)\"));\n@@ -923,16 +951,57 @@ static void show_bisect_in_progress(struct wt_status *s,\n \t\t\t\tstruct wt_status_state *state,\n \t\t\t\tconst char *color)\n {\n-\tstatus_printf_ln(s, color, _(\"You are currently bisecting.\"));\n+\tif (state->branch)\n+\t\tstatus_printf_ln(s, color,\n+\t\t\t\t _(\"You are currently bisecting branch '%s'.\"),\n+\t\t\t\t state->branch);\n+\telse\n+\t\tstatus_printf_ln(s, color,\n+\t\t\t\t _(\"You are currently bisecting.\"));\n \tif (advice_status_hints)\n \t\tstatus_printf_ln(s, color,\n \t\t\t_(\"  (use \\\"git bisect reset\\\" to get back to the original branch)\"));\n \twt_status_print_trailer(s);\n }\n \n+/*\n+ * Extract branch information from rebase/bisect\n+ */\n+static void read_and_strip_branch(struct strbuf *sb,\n+\t\t\t\t  const char **branch,\n+\t\t\t\t  const char *path)\n+{\n+\tunsigned char sha1[20];\n+\n+\tstrbuf_reset(sb);\n+\tif (strbuf_read_file(sb, git_path(\"%s\", path), 0) <= 0)\n+\t\treturn;\n+\n+\twhile (sb->len && sb->buf[sb->len - 1] == '\\n')\n+\t\tstrbuf_setlen(sb, sb->len - 1);\n+\tif (!sb->len)\n+\t\treturn;\n+\tif (!prefixcmp(sb->buf, \"refs/heads/\"))\n+\t\t*branch = sb->buf + strlen(\"refs/heads/\");\n+\telse if (!prefixcmp(sb->buf, \"refs/\"))\n+\t\t*branch = sb->buf;\n+\telse if (!get_sha1_hex(sb->buf, sha1)) {\n+\t\tconst char *abbrev;\n+\t\tabbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);\n+\t\tstrbuf_reset(sb);\n+\t\tstrbuf_addstr(sb, abbrev);\n+\t\t*branch = sb->buf;\n+\t} else if (!strcmp(sb->buf, \"detached HEAD\")) /* rebase */\n+\t\t;\n+\telse\t\t\t/* bisect */\n+\t\t*branch = sb->buf;\n+}\n+\n static void wt_status_print_state(struct wt_status *s)\n {\n \tconst char *state_color = color(WT_STATUS_HEADER, s);\n+\tstruct strbuf branch = STRBUF_INIT;\n+\tstruct strbuf onto = STRBUF_INIT;\n \tstruct wt_status_state state;\n \tstruct stat st;\n \n@@ -947,17 +1016,28 @@ static void wt_status_print_state(struct wt_status *s)\n \t\t\t\tstate.am_empty_patch = 1;\n \t\t} else {\n \t\t\tstate.rebase_in_progress = 1;\n+\t\t\tread_and_strip_branch(&branch, &state.branch,\n+\t\t\t\t\t      \"rebase-apply/head-name\");\n+\t\t\tread_and_strip_branch(&onto, &state.onto,\n+\t\t\t\t\t      \"rebase-apply/onto\");\n \t\t}\n \t} else if (!stat(git_path(\"rebase-merge\"), &st)) {\n \t\tif (!stat(git_path(\"rebase-merge/interactive\"), &st))\n \t\t\tstate.rebase_interactive_in_progress = 1;\n \t\telse\n \t\t\tstate.rebase_in_progress = 1;\n+\t\tread_and_strip_branch(&branch, &state.branch,\n+\t\t\t\t      \"rebase-merge/head-name\");\n+\t\tread_and_strip_branch(&onto, &state.onto,\n+\t\t\t\t      \"rebase-merge/onto\");\n \t} else if (!stat(git_path(\"CHERRY_PICK_HEAD\"), &st)) {\n \t\tstate.cherry_pick_in_progress = 1;\n \t}\n-\tif (!stat(git_path(\"BISECT_LOG\"), &st))\n+\tif (!stat(git_path(\"BISECT_LOG\"), &st)) {\n \t\tstate.bisect_in_progress = 1;\n+\t\tread_and_strip_branch(&branch, &state.branch,\n+\t\t\t\t      \"BISECT_START\");\n+\t}\n \n \tif (state.merge_in_progress)\n \t\tshow_merge_in_progress(s, &state, state_color);\n@@ -969,6 +1049,8 @@ static void wt_status_print_state(struct wt_status *s)\n \t\tshow_cherry_pick_in_progress(s, &state, state_color);\n \tif (state.bisect_in_progress)\n \t\tshow_bisect_in_progress(s, &state, state_color);\n+\tstrbuf_release(&branch);\n+\tstrbuf_release(&onto);\n }\n \n void wt_status_print(struct wt_status *s)\ndiff --git a/wt-status.h b/wt-status.h\nindex 236b41f..81e1dcf 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -79,6 +79,8 @@ struct wt_status_state {\n \tint rebase_interactive_in_progress;\n \tint cherry_pick_in_progress;\n \tint bisect_in_progress;\n+\tconst char *branch;\n+\tconst char *onto;\n };\n \n void wt_status_prepare(struct wt_status *s);\n-- \n1.8.1.1.459.g5970e58\n"},{"id":"208689","messageId":"20130205063847.GA3240@elie.Belkin","threadId":"32768","inReplyTo":"1359870807-22817-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v3] status: show the branch name if possible in in-progress info","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-02-05T06:38:47Z","receivedAt":"2013-02-05T06:38:47Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nMissing description.  Stealing from the link you sent:\n\n\tThe typical use-case is starting a rebase, do something else, come back\n\tthe day after, run \"git status\" or make a new commit and wonder what\n\tin the world's going on. Which branch is being rebased is probably the\n\tmost useful tidbit to help, but the target may help too.\n\n\tIdeally, I would have loved to see \"rebasing master on origin/master\",\n\tbut the target ref name is not stored during rebase, so this patch\n\twrites \"rebasing master on a78c8c98b\" as a half-measure to remind\n\tfuture users of that potential improvement.\n\n\tSigned-off-by: <...>\n"},{"id":"208724","messageId":"CACsJy8D_kSrJYagxo1LWt=P8XKj9F9_yAwH3vzQWQOi+yvP8kg@mail.gmail.com","threadId":"32768","inReplyTo":"20130205063847.GA3240@elie.Belkin","subject":"Re: [PATCH v3] status: show the branch name if possible in in-progress info","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-02-05T12:20:51Z","receivedAt":"2013-02-05T12:20:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Feb 5, 2013 at 1:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Missing description.  Stealing from the link you sent:\n>\n>         The typical use-case is starting a rebase, do something else, come back\n>         the day after, run \"git status\" or make a new commit and wonder what\n>         in the world's going on. Which branch is being rebased is probably the\n>         most useful tidbit to help, but the target may help too.\n>\n>         Ideally, I would have loved to see \"rebasing master on origin/master\",\n>         but the target ref name is not stored during rebase, so this patch\n>         writes \"rebasing master on a78c8c98b\" as a half-measure to remind\n>         future users of that potential improvement.\n>\n>         Signed-off-by: <...>\n\nLooking good. Junio, do you need a new patch mail or can you just\namend the commit message?\n-- \nDuy\n"},{"id":"208743","messageId":"7vmwviu3lx.fsf@alter.siamese.dyndns.org","threadId":"32768","inReplyTo":"CACsJy8D_kSrJYagxo1LWt=P8XKj9F9_yAwH3vzQWQOi+yvP8kg@mail.gmail.com","subject":"Re: [PATCH v3] status: show the branch name if possible in in-progress info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-05T16:28:42Z","receivedAt":"2013-02-05T16:28:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Tue, Feb 5, 2013 at 1:38 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Missing description.  Stealing from the link you sent:\n>>\n>>         The typical use-case is starting a rebase, do something else, come back\n>>         the day after, run \"git status\" or make a new commit and wonder what\n>>         in the world's going on. Which branch is being rebased is probably the\n>>         most useful tidbit to help, but the target may help too.\n>>\n>>         Ideally, I would have loved to see \"rebasing master on origin/master\",\n>>         but the target ref name is not stored during rebase, so this patch\n>>         writes \"rebasing master on a78c8c98b\" as a half-measure to remind\n>>         future users of that potential improvement.\n>>\n>>         Signed-off-by: <...>\n>\n> Looking good. Junio, do you need a new patch mail or can you just\n> amend the commit message?\n\nI'd like to see you either\n\n - send a reroll, making it clear it is a reroll, or\n - tell me to amend.\n\ninstead of asking which one I would prefer ;-)  One less message I\nhave to respond to that way.\n\n\"commit --amend\" done.\n"}]}