{"thread":{"id":"34193","subject":"[PATCH 0/8] Re-roll rr/rebase-checkout-reflog","startedAt":"2013-06-18T12:14:22Z","lastAt":"2013-06-18T16:56:10Z","messageCount":15,"participants":["Ramkumar Ramachandra","Peter Krefting","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"221190","messageId":"1371557670-12534-1-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":null,"subject":"[PATCH 0/8] Re-roll rr/rebase-checkout-reflog","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:22Z","receivedAt":"2013-06-18T12:14:22Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"This is a re-roll for rr/rebase-checkout-reflog, which is queued in\n`pu`.\n\nI've reviewed the changes carefully, and I believe that they are all\ncorrect.  I've added a [6/8], because I think it is the correct way to\nunset GIT_REFLOG_ACTION.\n\nJunio: there is no need to re-export GIT_REFLOG_ACTION every time we\nset it.  I've also fixed up some of your commit messages.  Let me know\nif any further tweaks are necessary.\n\nThanks.\n\nJunio C Hamano (1):\n  t/status-help: test \"HEAD detached from\"\n\nRamkumar Ramachandra (7):\n  wt-status: remove unused field in grab_1st_switch_cbdata\n  t/checkout-last: test \"checkout -\" after a rebase\n  status: do not depend on rebase reflog messages\n  checkout: respect GIT_REFLOG_ACTION\n  sh-setup: make die_with_status clear GIT_REFLOG_ACTION\n  rebase: write better reflog messages\n  rebase -i: write better reflog messages\n\n builtin/checkout.c         | 11 ++++++++---\n git-rebase--am.sh          |  2 ++\n git-rebase--interactive.sh |  3 +++\n git-rebase.sh              |  8 +++++++-\n git-sh-setup.sh            |  1 +\n t/t2012-checkout-last.sh   | 34 +++++++++++++++++++++++++++++++++\n t/t7512-status-help.sh     | 47 +++++++++++++++++++++++++---------------------\n wt-status.c                |  7 ++++---\n 8 files changed, 85 insertions(+), 28 deletions(-)\n\n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221194","messageId":"1371557670-12534-2-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 1/8] t/status-help: test \"HEAD detached from\"","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:23Z","receivedAt":"2013-06-18T12:14:23Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nb397ea (status: show more info than \"currently not on any branch\",\n2013-03-13) wanted to make sure that after a checkout to detach HEAD,\nthe user can see where the HEAD was originally detached from.  The last\ntest added by that commit to t/status-help shows one example,\nimmediately after HEAD is detached via a checkout.  Enhance that test to\ntest the \"HEAD detached from\" message is displayed when the user further\nresets to another commit.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n t/t7512-status-help.sh | 10 +++++++++-\n 1 file changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex bf08d4e..bafa5e7 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -667,7 +667,7 @@ test_expect_success 'status when cherry-picking after resolving conflicts' '\n \ttest_i18ncmp expected actual\n '\n \n-test_expect_success 'status showing detached from a tag' '\n+test_expect_success 'status showing detached at and from a tag' '\n \ttest_commit atag tagging &&\n \tgit checkout atag &&\n \tcat >expected <<-\\EOF\n@@ -675,6 +675,14 @@ test_expect_success 'status showing detached from a tag' '\n \tnothing to commit (use -u to show untracked files)\n \tEOF\n \tgit status --untracked-files=no >actual &&\n+\ttest_i18ncmp expected actual &&\n+\n+\tgit reset --hard HEAD^ &&\n+\tcat >expected <<-\\EOF\n+\t# HEAD detached from atag\n+\tnothing to commit (use -u to show untracked files)\n+\tEOF\n+\tgit status --untracked-files=no >actual &&\n \ttest_i18ncmp expected actual\n '\n \n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221195","messageId":"1371557670-12534-3-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 2/8] wt-status: remove unused field in grab_1st_switch_cbdata","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:24Z","receivedAt":"2013-06-18T12:14:24Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"The struct grab_1st_switch_cbdata has the field \"found\", which is\nset in grab_1st_switch() when a match is found.  This information is\nredundant and unused by any code.  The return value of the function\nserves to communicate this information anyway.\n\nRemove the field.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n wt-status.c | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex bf84a86..2511270 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1035,7 +1035,6 @@ got_nothing:\n }\n \n struct grab_1st_switch_cbdata {\n-\tint found;\n \tstruct strbuf buf;\n \tunsigned char nsha1[20];\n };\n@@ -1059,7 +1058,6 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,\n \tfor (end = target; *end && *end != '\\n'; end++)\n \t\t;\n \tstrbuf_add(&cb->buf, target, end - target);\n-\tcb->found = 1;\n \treturn 1;\n }\n \n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221192","messageId":"1371557670-12534-4-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 3/8] t/checkout-last: test \"checkout -\" after a rebase","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:25Z","receivedAt":"2013-06-18T12:14:25Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"  $ git checkout -\n\ndoes not work as expected after a rebase.  This is because the\nreflog records \"checkout\" made by \"rebase\" as its implementation\ndetail the same way as end-user initiated \"checkout\", and makes it\ncount as the branch that was previously checked out.\n\nAdd four failing tests documenting this bug: two for a normal rebase,\nand another two for an interactive rebase.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t2012-checkout-last.sh | 34 ++++++++++++++++++++++++++++++++++\n 1 file changed, 34 insertions(+)\n\ndiff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh\nindex b44de9d..6ad6edf 100755\n--- a/t/t2012-checkout-last.sh\n+++ b/t/t2012-checkout-last.sh\n@@ -116,4 +116,38 @@ test_expect_success 'master...' '\n \ttest \"z$(git rev-parse --verify HEAD)\" = \"z$(git rev-parse --verify master^)\"\n '\n \n+test_expect_failure '\"checkout -\" works after a rebase A' '\n+\tgit checkout master &&\n+\tgit checkout other &&\n+\tgit rebase master &&\n+\tgit checkout - &&\n+\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n+'\n+\n+test_expect_failure '\"checkout -\" works after a rebase A B' '\n+\tgit branch moodle master~1 &&\n+\tgit checkout master &&\n+\tgit checkout other &&\n+\tgit rebase master moodle &&\n+\tgit checkout - &&\n+\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n+'\n+\n+test_expect_failure '\"checkout -\" works after a rebase -i A' '\n+\tgit checkout master &&\n+\tgit checkout other &&\n+\tgit rebase -i master &&\n+\tgit checkout - &&\n+\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n+'\n+\n+test_expect_failure '\"checkout -\" works after a rebase -i A B' '\n+\tgit branch foodle master~1 &&\n+\tgit checkout master &&\n+\tgit checkout other &&\n+\tgit rebase master foodle &&\n+\tgit checkout - &&\n+\ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n+'\n+\n test_done\n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221193","messageId":"1371557670-12534-5-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 4/8] status: do not depend on rebase reflog messages","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:26Z","receivedAt":"2013-06-18T12:14:26Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"b397ea4 (status: show more info than \"currently not on any branch\",\n2013-03-13) attempted to make the output of 'git status' richer in\nthe case of a detached HEAD.  Before this patch, with a detached\nHEAD, we saw:\n\n  $ git status\n  # Not currently on any branch.\n\nBut after the patch, we see:\n\n  $ git checkout v1.8.2\n  $ git status\n  # HEAD detached at v1.8.2\n\nIt works by digging the reflog for the most recent message of the\nform \"checkout: moving from xxxx to yyyy\".  It then asserts that\nHEAD and \"yyyy\" are the same, and displays this message.  When they\naren't equal, it displays:\n\n  $ git status\n  # HEAD detached from fe11db\n\nso that the user can see where the HEAD was first detached.\n\nIn case of a rebase [-i] operation in progress, this message depends on\nthe implementation of rebase writing \"checkout: \" messages to the\nreflog, but that is an implementation detail of \"rebase\".  To remove\nthis dependency so that rebase can be updated to write better reflog\nmessages, replace this \"HEAD detached from\" message with:\n\n  # rebase in progress; onto $ONTO\n\nChanges to the commit object name in the expected output for some of the\ntests shows that what the test expected \"status\" to show during \"rebase\n-i\" was not consistent with the output during a vanilla \"rebase\", which\nshowed on top of what commit the series is being replayed.  Now we\nconsistently show something meaningful to the end user.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t7512-status-help.sh | 37 +++++++++++++++++--------------------\n wt-status.c            |  5 ++++-\n 2 files changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh\nindex bafa5e7..d6c66d7 100755\n--- a/t/t7512-status-help.sh\n+++ b/t/t7512-status-help.sh\n@@ -77,7 +77,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'\n \tONTO=$(git rev-parse --short HEAD^^) &&\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached at $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -104,7 +104,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '\n \techo three >main.txt &&\n \tgit add main.txt &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached at $ONTO\n+\t# rebase in progress; onto $ONTO\n \t# You are currently rebasing branch '\\''rebase_conflicts'\\'' on '\\''$ONTO'\\''.\n \t#   (all conflicts fixed: run \"git rebase --continue\")\n \t#\n@@ -136,7 +136,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '\n \tONTO=$(git rev-parse --short rebase_i_conflicts) &&\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached at $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -162,7 +162,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '\n \ttest_must_fail git rebase -i rebase_i_conflicts &&\n \tgit add main.txt &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached at $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -188,10 +188,9 @@ test_expect_success 'status when rebasing -i in edit mode' '\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n \tONTO=$(git rev-parse --short HEAD~2) &&\n-\tTGT=$(git rev-parse --short two_rebase_i) &&\n \tgit rebase -i HEAD~2 &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $TGT\n+\t# rebase in progress; onto $ONTO\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@@ -216,9 +215,8 @@ test_expect_success 'status when splitting a commit' '\n \tONTO=$(git rev-parse --short HEAD~3) &&\n \tgit rebase -i HEAD~3 &&\n \tgit reset HEAD^ &&\n-\tTGT=$(git rev-parse --short HEAD) &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached at $TGT\n+\t# rebase in progress; onto $ONTO\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@@ -246,11 +244,10 @@ test_expect_success 'status after editing the last commit with --amend during a\n \texport FAKE_LINES &&\n \ttest_when_finished \"git rebase --abort\" &&\n \tONTO=$(git rev-parse --short HEAD~3) &&\n-\tTGT=$(git rev-parse --short three_amend) &&\n \tgit rebase -i HEAD~3 &&\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $TGT\n+\t# rebase in progress; onto $ONTO\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@@ -280,7 +277,7 @@ test_expect_success 'status: (continue first edit) second edit' '\n \tgit rebase -i HEAD~3 &&\n \tgit rebase --continue &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -302,7 +299,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -329,7 +326,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '\n \tgit rebase --continue &&\n \tgit commit --amend -m \"foo\" &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -351,7 +348,7 @@ test_expect_success 'status: (amend first edit) second edit' '\n \tgit commit --amend -m \"a\" &&\n \tgit rebase --continue &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -374,7 +371,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -402,7 +399,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '\n \tgit rebase --continue &&\n \tgit commit --amend -m \"d\" &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -426,7 +423,7 @@ test_expect_success 'status: (split first edit) second edit' '\n \tgit commit -m \"e\" &&\n \tgit rebase --continue &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -451,7 +448,7 @@ test_expect_success 'status: (split first edit) second edit and split' '\n \tgit rebase --continue &&\n \tgit reset HEAD^ &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -481,7 +478,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '\n \tgit rebase --continue &&\n \tgit commit --amend -m \"h\" &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached from $ONTO\n+\t# rebase in progress; onto $ONTO\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@@ -601,7 +598,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '\n \tONTO=$(git rev-parse --short HEAD^^) &&\n \ttest_must_fail git rebase HEAD^ --onto HEAD^^ &&\n \tcat >expected <<-EOF &&\n-\t# HEAD detached at $ONTO\n+\t# rebase in progress; onto $ONTO\n \t# You are currently rebasing branch '\\''statushints_disabled'\\'' on '\\''$ONTO'\\''.\n \t#\n \t# Unmerged paths:\ndiff --git a/wt-status.c b/wt-status.c\nindex 2511270..85a00f1 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1174,7 +1174,10 @@ void wt_status_print(struct wt_status *s)\n \t\t\tbranch_name += 11;\n \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n \t\t\tbranch_status_color = color(WT_STATUS_NOBRANCH, s);\n-\t\t\tif (state.detached_from) {\n+\t\t\tif (state.rebase_in_progress || state.rebase_interactive_in_progress) {\n+\t\t\t\ton_what = _(\"rebase in progress; onto \");\n+\t\t\t\tbranch_name = state.onto;\n+\t\t\t} else if (state.detached_from) {\n \t\t\t\tunsigned char sha1[20];\n \t\t\t\tbranch_name = state.detached_from;\n \t\t\t\tif (!get_sha1(\"HEAD\", sha1) &&\n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221191","messageId":"1371557670-12534-6-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 5/8] checkout: respect GIT_REFLOG_ACTION","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:27Z","receivedAt":"2013-06-18T12:14:27Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"GIT_REFLOG_ACTION is an environment variable specifying the reflog\nmessage to write after an action is completed.  Several other commands\nincluding merge, reset, and commit respect it.\n\nFix the failing tests in t/checkout-last by making checkout respect it\ntoo.  You can now expect\n\n  $ git checkout -\n\nto work as expected after any a rebase [-i].  It will also work with any\nother scripts provided they set an appropriate GIT_REFLOG_ACTION if they\ninternally use \"git checkout\".\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/checkout.c       | 11 ++++++++---\n t/t2012-checkout-last.sh |  8 ++++----\n 2 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex f5b50e5..1e2af85 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -587,7 +587,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,\n \t\t\t\t   struct branch_info *new)\n {\n \tstruct strbuf msg = STRBUF_INIT;\n-\tconst char *old_desc;\n+\tconst char *old_desc, *reflog_msg;\n \tif (opts->new_branch) {\n \t\tif (opts->new_orphan_branch) {\n \t\t\tif (opts->new_branch_log && !log_all_ref_updates) {\n@@ -620,8 +620,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,\n \told_desc = old->name;\n \tif (!old_desc && old->commit)\n \t\told_desc = sha1_to_hex(old->commit->object.sha1);\n-\tstrbuf_addf(&msg, \"checkout: moving from %s to %s\",\n-\t\t    old_desc ? old_desc : \"(invalid)\", new->name);\n+\n+\treflog_msg = getenv(\"GIT_REFLOG_ACTION\");\n+\tif (!reflog_msg)\n+\t\tstrbuf_addf(&msg, \"checkout: moving from %s to %s\",\n+\t\t\told_desc ? old_desc : \"(invalid)\", new->name);\n+\telse\n+\t\tstrbuf_insert(&msg, 0, reflog_msg, strlen(reflog_msg));\n \n \tif (!strcmp(new->name, \"HEAD\") && !new->path && !opts->force_detach) {\n \t\t/* Nothing to do. */\ndiff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh\nindex 6ad6edf..e7ba8c5 100755\n--- a/t/t2012-checkout-last.sh\n+++ b/t/t2012-checkout-last.sh\n@@ -116,7 +116,7 @@ test_expect_success 'master...' '\n \ttest \"z$(git rev-parse --verify HEAD)\" = \"z$(git rev-parse --verify master^)\"\n '\n \n-test_expect_failure '\"checkout -\" works after a rebase A' '\n+test_expect_success '\"checkout -\" works after a rebase A' '\n \tgit checkout master &&\n \tgit checkout other &&\n \tgit rebase master &&\n@@ -124,7 +124,7 @@ test_expect_failure '\"checkout -\" works after a rebase A' '\n \ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n '\n \n-test_expect_failure '\"checkout -\" works after a rebase A B' '\n+test_expect_success '\"checkout -\" works after a rebase A B' '\n \tgit branch moodle master~1 &&\n \tgit checkout master &&\n \tgit checkout other &&\n@@ -133,7 +133,7 @@ test_expect_failure '\"checkout -\" works after a rebase A B' '\n \ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n '\n \n-test_expect_failure '\"checkout -\" works after a rebase -i A' '\n+test_expect_success '\"checkout -\" works after a rebase -i A' '\n \tgit checkout master &&\n \tgit checkout other &&\n \tgit rebase -i master &&\n@@ -141,7 +141,7 @@ test_expect_failure '\"checkout -\" works after a rebase -i A' '\n \ttest \"z$(git symbolic-ref HEAD)\" = \"zrefs/heads/master\"\n '\n \n-test_expect_failure '\"checkout -\" works after a rebase -i A B' '\n+test_expect_success '\"checkout -\" works after a rebase -i A B' '\n \tgit branch foodle master~1 &&\n \tgit checkout master &&\n \tgit checkout other &&\n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221196","messageId":"1371557670-12534-7-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 6/8] sh-setup: make die_with_status clear GIT_REFLOG_ACTION","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:28Z","receivedAt":"2013-06-18T12:14:28Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Several callers set GIT_REFLOG_ACTION via set_reflog_action(), but\nnobody unsets it, leaving a potentially stray variable in the\nenvironment.  Fix this by making die_with_status() unset it.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n git-sh-setup.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 2f78359..3297103 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -51,6 +51,7 @@ die () {\n }\n \n die_with_status () {\n+\texport GIT_REFLOG_ACTION=\n \tstatus=$1\n \tshift\n \techo >&2 \"$*\"\n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221197","messageId":"1371557670-12534-8-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 7/8] rebase: write better reflog messages","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:29Z","receivedAt":"2013-06-18T12:14:29Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Now that the \"checkout\" invoked internally from \"rebase\" knows to honor\nGIT_REFLOG_ACTION, we can start to use it to write a better reflog\nmessage when \"rebase anotherbranch\", \"rebase --onto branch\",\netc. internally checks out the new fork point.  We will write:\n\n  rebase: checkout master\n\ninstead of the old\n\n  rebase\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-rebase--am.sh | 2 ++\n git-rebase.sh     | 8 +++++++-\n 2 files changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 34e3102..d4bade8 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -40,9 +40,11 @@ else\n \t\trm -f \"$GIT_DIR/rebased-patches\"\n \t\tcase \"$head_name\" in\n \t\trefs/heads/*)\n+\t\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $head_name\"\n \t\t\tgit checkout -q \"$head_name\"\n \t\t\t;;\n \t\t*)\n+\t\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $orig_head\"\n \t\t\tgit checkout -q \"$orig_head\"\n \t\t\t;;\n \t\tesac\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d0c11a9..b43600d 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -543,7 +543,11 @@ then\n \tif test -z \"$force_rebase\"\n \tthen\n \t\t# Lazily switch to the target branch if needed...\n-\t\ttest -z \"$switch_to\" || git checkout \"$switch_to\" --\n+\t\tif test -n \"$switch_to\"\n+\t\tthen\n+\t\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\"\n+\t\t\tgit checkout \"$switch_to\" --\n+\t\tfi\n \t\tsay \"$(eval_gettext \"Current branch \\$branch_name is up to date.\")\"\n \t\texit 0\n \telse\n@@ -568,6 +572,8 @@ test \"$type\" = interactive && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"$(gettext \"First, rewinding head to replay your work on top of it...\")\"\n+\n+GIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $onto_name\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n git update-ref ORIG_HEAD $orig_head\n \n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221198","messageId":"1371557670-12534-9-git-send-email-artagnon@gmail.com","threadId":"34193","inReplyTo":"1371557670-12534-1-git-send-email-artagnon@gmail.com","subject":"[PATCH 8/8] rebase -i: write better reflog messages","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T12:14:30Z","receivedAt":"2013-06-18T12:14:30Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Now that the \"checkout\" invoked internally from \"rebase -i\" knows to\nhonor GIT_REFLOG_ACTION, we can start to use it to write a better reflog\nmessage when \"rebase -i anotherbranch\", \"rebase -i --onto branch\",\netc. internally checks out the new fork point.  We will write:\n\n  rebase -i (start): checkout master\n\ninstead of the old\n\n  rebase -i (start)\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-rebase--interactive.sh | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex f953d8d..5179500 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -326,6 +326,7 @@ pick_one_preserving_merges () {\n \t\tif [ \"$1\" != \"-n\" ]\n \t\tthen\n \t\t\t# detach HEAD to current parent\n+\t\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $first_parent\"\n \t\t\toutput git checkout $first_parent 2> /dev/null ||\n \t\t\t\tdie \"Cannot move HEAD to $first_parent\"\n \t\tfi\n@@ -838,6 +839,7 @@ comment_for_reflog start\n \n if test ! -z \"$switch_to\"\n then\n+\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\"\n \toutput git checkout \"$switch_to\" -- ||\n \t\tdie \"Could not checkout $switch_to\"\n fi\n@@ -981,6 +983,7 @@ has_action \"$todo\" ||\n \n test -d \"$rewritten\" || test -n \"$force_rebase\" || skip_unnecessary_picks\n \n+GIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $onto_name\"\n output git checkout $onto || die_abort \"could not detach HEAD\"\n git update-ref ORIG_HEAD $orig_head\n do_rest\n-- \n1.8.3.1.456.gb7f4cb6\n"},{"id":"221211","messageId":"alpine.DEB.2.00.1306181338330.10630@perkele.intern.softwolves.pp.se","threadId":"34193","inReplyTo":"1371557670-12534-5-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 4/8] status: do not depend on rebase reflog messages","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2013-06-18T12:40:07Z","receivedAt":"2013-06-18T12:40:07Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Ramkumar Ramachandra:\n\n> +\t\t\t\ton_what = _(\"rebase in progress; onto \");\n\nCould you please add a\n\n   /* TRANSLATORS: Followed by branch name. */\n\nor something similar here (and possibly to the other \"on_what\"s in the \nfunction)?\n\nIdeally, the \"%s\" for the branch name should be inside that \non_what string, but I guess that can be difficult since it is output \nin a different colour?\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"221237","messageId":"7vbo738na9.fsf@alter.siamese.dyndns.org","threadId":"34193","inReplyTo":"1371557670-12534-7-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 6/8] sh-setup: make die_with_status clear GIT_REFLOG_ACTION","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-18T15:13:34Z","receivedAt":"2013-06-18T15:13:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Several callers set GIT_REFLOG_ACTION via set_reflog_action(), but\n> nobody unsets it, leaving a potentially stray variable in the\n> environment.  Fix this by making die_with_status() unset it.\n\nI am totally lost.\n\n - You can set your own environment variables, and they will affect\n   your child processes' environment, but only _before_ you spawn\n   them.  After you spawn them, changes to your environment will not\n   affect your child processes' environment.\n\n - There is no mechanism for you to affect environment of your\n   parent process.\n\n - And we are exiting the process by calling die_with_status.\n\nWhose environment are you trying to affect (or not affect) with this\nchange?  This will not affect your children, this will not affect\nyour parent, and this will not help you, either.\n\nPuzzled.\n\n>\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  git-sh-setup.sh | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index 2f78359..3297103 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -51,6 +51,7 @@ die () {\n>  }\n>  \n>  die_with_status () {\n> +\texport GIT_REFLOG_ACTION=\n>  \tstatus=$1\n>  \tshift\n>  \techo >&2 \"$*\"\n"},{"id":"221243","messageId":"CALkWK0kE1g5k=TxJCBQoHi+o7SZD5skQ2s6utxEgeuK=_C9ULg@mail.gmail.com","threadId":"34193","inReplyTo":"7vbo738na9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 6/8] sh-setup: make die_with_status clear GIT_REFLOG_ACTION","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T15:47:09Z","receivedAt":"2013-06-18T15:47:09Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n>  - There is no mechanism for you to affect environment of your\n>    parent process.\n\nPlease excuse my stupidity and drop this patch.  I got mislead by your\nSQUASH??? patch which took care to set the environment variable and\ncall checkout in a subshell.\n"},{"id":"221256","messageId":"7vwqpr5q9q.fsf@alter.siamese.dyndns.org","threadId":"34193","inReplyTo":"CALkWK0kE1g5k=TxJCBQoHi+o7SZD5skQ2s6utxEgeuK=_C9ULg@mail.gmail.com","subject":"Re: [PATCH 6/8] sh-setup: make die_with_status clear GIT_REFLOG_ACTION","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-18T16:37:21Z","receivedAt":"2013-06-18T16:37:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Please excuse my stupidity and drop this patch.  \n\nHeh, we always have brain-fart every once in a while.  Your\nstupidity is always gladly excused ;-)\n\n> I got mislead by your SQUASH??? patch which took care to set the\n> environment variable and call checkout in a subshell.\n\nTo some, we could have done\n\n\tENV_VAR=\"$ENV_VAR: some other string\" command\n\nbut there were uses of \"output\" shell function in some instances,\nand\n\n\tVAR=VAL shell_function\n\ndoes not work, so that was the reason why\n\n\t(\n        \tVAR=VAL; export VAR\n                shell_function\n\t)\n\nform was used.\n"},{"id":"221261","messageId":"7vli675pi8.fsf@alter.siamese.dyndns.org","threadId":"34193","inReplyTo":"1371557670-12534-6-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH 5/8] checkout: respect GIT_REFLOG_ACTION","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-18T16:53:51Z","receivedAt":"2013-06-18T16:53:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramkumar Ramachandra <artagnon@gmail.com> writes:\n\n> Fix the failing tests in t/checkout-last by making checkout respect it\n> too.  You can now expect\n>\n>   $ git checkout -\n>\n> to work as expected after any a rebase [-i].  It will also work with any\n> other scripts provided they set an appropriate GIT_REFLOG_ACTION if they\n> internally use \"git checkout\".\n\nYes, it is better to clearly say that this just opens the door to\nfix others and at this step \"rebase\" is the primary thing that is\nfixed.\n\nBy the way, please stop doing \"t/checkout-last\" which I have to\nmanually fix-up every time to its actual prefix (i.e. I cannot\nreview with \"less t/checkout-last*\" to see what the log message is\ntalking about; I can with \"less t/t2012-checkout-last*\").\n"},{"id":"221262","messageId":"CALkWK0mfDeO5V9J9txjwATRxSRDPY2fJ0mNRCA7VoqKiQgWpiw@mail.gmail.com","threadId":"34193","inReplyTo":"7vli675pi8.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 5/8] checkout: respect GIT_REFLOG_ACTION","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-06-18T16:56:10Z","receivedAt":"2013-06-18T16:56:10Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Junio C Hamano wrote:\n> By the way, please stop doing \"t/checkout-last\" which I have to\n> manually fix-up every time to its actual prefix (i.e. I cannot\n> review with \"less t/checkout-last*\" to see what the log message is\n> talking about; I can with \"less t/t2012-checkout-last*\").\n\nAh, I didn't realize you used it like that.  I was trying to be terse\nand informative in the subject: the four test numbers don't mean\nanything to a casual reader, while t/checkout-last conveys\ninformation.\n"}]}