{"thread":{"id":"49918","subject":"[PATCH 0/1] Fix built-in rebase regression noticed by Debian's dgit","startedAt":"2018-11-29T19:09:23Z","lastAt":"2018-11-29T19:09:25Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"364350","messageId":"pull.91.git.gitgitgadget@gmail.com","threadId":"49918","inReplyTo":null,"subject":"[PATCH 0/1] Fix built-in rebase regression noticed by Debian's dgit","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-29T19:09:20Z","receivedAt":"2018-11-29T19:09:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"It has been reported on the Debian bug tracker\n[https://bugs.debian.org/914695] that the built-in rebase regresses on the\nscripted version, and later details emerged that this has something to do\nwith the reflog messages: they were different with the built-in rebase than\nwith the scripted one.\n\nThis here patch fixes that.\n\nJohannes Schindelin (1):\n  rebase: fix GIT_REFLOG_ACTION regression\n\n builtin/rebase.c          | 29 ++++++++++++++++++++++++++---\n t/t3406-rebase-message.sh | 26 ++++++++++++++++++++++++++\n 2 files changed, 52 insertions(+), 3 deletions(-)\n\n\nbase-commit: 7068cbc4abac53d9c3675dfba81c1e97d25e8eeb\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-91%2Fdscho%2Ffix-reflog-action-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-91/dscho/fix-reflog-action-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/91\n-- \ngitgitgadget\n"},{"id":"364351","messageId":"3295df5829e245a7dba80d3cb669a797ae42ebb9.1543518559.git.gitgitgadget@gmail.com","threadId":"49918","inReplyTo":"pull.91.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] rebase: fix GIT_REFLOG_ACTION regression","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-29T19:09:21Z","receivedAt":"2018-11-29T19:09:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe scripted version (partially) heeded the `GIT_REFLOG_ACTION` and when\nwe converted to a built-in, this regressed.\n\nFix that, and add a regression test, both with `GIT_REFLOG_ACTION` set\nand unset.\n\nNote: the reflog message for \"rebase finished\" did *not* heed\nGIT_REFLOG_ACTION, and as we are very late in the v2.20.0-rcN phase, we\nleave that bug for later (as it seems that that bug has been with us\nfrom the very beginning).\n\nReported by Ian Jackson.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/rebase.c          | 29 ++++++++++++++++++++++++++---\n t/t3406-rebase-message.sh | 26 ++++++++++++++++++++++++++\n 2 files changed, 52 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 5b3e5baec8..ba0c3c954b 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -776,6 +776,23 @@ static void NORETURN error_on_missing_default_upstream(void)\n \texit(1);\n }\n \n+static void set_reflog_action(struct rebase_options *options)\n+{\n+\tconst char *env;\n+\tstruct strbuf buf = STRBUF_INIT;\n+\n+\tif (!is_interactive(options))\n+\t\treturn;\n+\n+\tenv = getenv(GIT_REFLOG_ACTION_ENVIRONMENT);\n+\tif (env && strcmp(\"rebase\", env))\n+\t\treturn; /* only override it if it is \"rebase\" */\n+\n+\tstrbuf_addf(&buf, \"rebase -i (%s)\", options->action);\n+\tsetenv(GIT_REFLOG_ACTION_ENVIRONMENT, buf.buf, 1);\n+\tstrbuf_release(&buf);\n+}\n+\n int cmd_rebase(int argc, const char **argv, const char *prefix)\n {\n \tstruct rebase_options options = {\n@@ -978,6 +995,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \n \tif (action != NO_ACTION && !in_progress)\n \t\tdie(_(\"No rebase in progress?\"));\n+\tsetenv(GIT_REFLOG_ACTION_ENVIRONMENT, \"rebase\", 0);\n \n \tif (action == ACTION_EDIT_TODO && !is_interactive(&options))\n \t\tdie(_(\"The --edit-todo action can only be used during \"\n@@ -990,6 +1008,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\tint fd;\n \n \t\toptions.action = \"continue\";\n+\t\tset_reflog_action(&options);\n \n \t\t/* Sanity check */\n \t\tif (get_oid(\"HEAD\", &head))\n@@ -1018,6 +1037,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n \n \t\toptions.action = \"skip\";\n+\t\tset_reflog_action(&options);\n \n \t\trerere_clear(&merge_rr);\n \t\tstring_list_clear(&merge_rr, 1);\n@@ -1033,6 +1053,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \tcase ACTION_ABORT: {\n \t\tstruct string_list merge_rr = STRING_LIST_INIT_DUP;\n \t\toptions.action = \"abort\";\n+\t\tset_reflog_action(&options);\n \n \t\trerere_clear(&merge_rr);\n \t\tstring_list_clear(&merge_rr, 1);\n@@ -1440,11 +1461,12 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\t\t}\n \n \t\t\t\tstrbuf_reset(&buf);\n-\t\t\t\tstrbuf_addf(&buf, \"rebase: checkout %s\",\n+\t\t\t\tstrbuf_addf(&buf, \"%s: checkout %s\",\n+\t\t\t\t\t    getenv(GIT_REFLOG_ACTION_ENVIRONMENT),\n \t\t\t\t\t    options.switch_to);\n \t\t\t\tif (reset_head(&oid, \"checkout\",\n \t\t\t\t\t       options.head_name, 0,\n-\t\t\t\t\t       NULL, NULL) < 0) {\n+\t\t\t\t\t       NULL, buf.buf) < 0) {\n \t\t\t\t\tret = !!error(_(\"could not switch to \"\n \t\t\t\t\t\t\t\"%s\"),\n \t\t\t\t\t\t      options.switch_to);\n@@ -1508,7 +1530,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\tprintf(_(\"First, rewinding head to replay your work on top of \"\n \t\t\t \"it...\\n\"));\n \n-\tstrbuf_addf(&msg, \"rebase: checkout %s\", options.onto_name);\n+\tstrbuf_addf(&msg, \"%s: checkout %s\",\n+\t\t    getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);\n \tif (reset_head(&options.onto->object.oid, \"checkout\", NULL,\n \t\t       RESET_HEAD_DETACH, NULL, msg.buf))\n \t\tdie(_(\"Could not detach HEAD\"));\ndiff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh\nindex 38bd876cab..db8505eb86 100755\n--- a/t/t3406-rebase-message.sh\n+++ b/t/t3406-rebase-message.sh\n@@ -91,4 +91,30 @@ test_expect_success 'error out early upon -C<n> or --whitespace=<bad>' '\n \ttest_i18ngrep \"Invalid whitespace option\" err\n '\n \n+test_expect_success 'GIT_REFLOG_ACTION' '\n+\tgit checkout start &&\n+\ttest_commit reflog-onto &&\n+\tgit checkout -b reflog-topic start &&\n+\ttest_commit reflog-to-rebase &&\n+\n+\tgit rebase reflog-onto &&\n+\tgit log -g --format=%gs -3 >actual &&\n+\tcat >expect <<-\\EOF &&\n+\trebase finished: returning to refs/heads/reflog-topic\n+\trebase: reflog-to-rebase\n+\trebase: checkout reflog-onto\n+\tEOF\n+\ttest_cmp expect actual &&\n+\n+\tgit checkout -b reflog-prefix reflog-to-rebase &&\n+\tGIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto &&\n+\tgit log -g --format=%gs -3 >actual &&\n+\tcat >expect <<-\\EOF &&\n+\trebase finished: returning to refs/heads/reflog-prefix\n+\tchange-the-reflog: reflog-to-rebase\n+\tchange-the-reflog: checkout reflog-onto\n+\tEOF\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \ngitgitgadget\n"}]}