{"thread":{"id":"57173","subject":"[BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","startedAt":"2022-01-03T18:08:26Z","lastAt":"2022-01-04T23:20:31Z","messageCount":6,"participants":["Tilman Vogel","Philip Oakley","Philippe Blain"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"445365","messageId":"9749fa2c-b08d-c08b-ce43-041d13852d02@web.de","threadId":"57173","inReplyTo":null,"subject":"[BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","fromName":"Tilman Vogel","fromEmail":"tilman.vogel@web.de","sentAt":"2022-01-03T18:08:21Z","receivedAt":"2022-01-03T18:08:26Z","isPatch":false,"sender":{"key":"tilman.vogel@web.de","avatar":"https://avatars.githubusercontent.com/u/349303?v=4"},"body":"Hi git-people,\n\nI ran into strange behavior when having rebase.autostash enabled and\ndoing a git pull --rebase:\n\n> git config rebase.autostash true\n> git pull --rebase\nUpdating cd9ff8a..f3c9840\nerror: Your local changes to the following files would be overwritten by\nmerge:\n        content\nPlease commit your changes or stash them before you merge.\nAborting\n\nConfusingly, this fixes the issue:\n\n> git config merge.autostash true\n> git pull --rebase\nUpdating cd9ff8a..f3c9840\nCreated autostash: c615fda\nFast-forward\n content | 1 +\n 1 file changed, 1 insertion(+)\nApplied autostash.\n\nLeaving me wonder why merge config options fix rebase behavior.\n\nSo, in order to make it easier to check the problem, I added some\ntest-cases to the git test-suite. Please see the attached patch.\n\nOr here:\nhttps://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705\n\nI did not try to find the root-cause as I am not experienced with the\ncode-base but if there are questions, let me know.\n\nBest regards,\n\nTilman\n\n\nFrom bc941f9357518a34cfa11788dfb8e7fa7f711705 Mon Sep 17 00:00:00 2001\nFrom: Tilman Vogel <tilman.vogel@web.de>\nDate: Mon, 3 Jan 2022 18:31:59 +0100\nSubject: [PATCH] t5521: Show inconsistent rebase behavior (--autostash vs.\n rebase.autostash)\n\nWhen pull --rebase can be done as a fast-forward, the rebase.autostash\nconfig is neglected such that the second test-case added in this commit\nwill fail to autostash and succeed.\nIn fact, setting merge.autostash as a workaround would cause autostash to\nbe done.\n\nThe other three test-cases added in this commit document that autostashing\nworks as expected when either requested explicitly with --autostash or when\npull --rebase cannot be done as a fast-forward.\n\nSigned-off-by: Tilman Vogel <tilman.vogel@web.de>\n---\n t/t5521-pull-options.sh | 52 +++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 52 insertions(+)\n\ndiff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh\nindex 66cfcb09c5..4046a74cad 100755\n--- a/t/t5521-pull-options.sh\n+++ b/t/t5521-pull-options.sh\n@@ -252,4 +252,56 @@ test_expect_success 'git pull --no-verify --verify passed to merge' '\n \ttest_must_fail git -C dst pull --no-ff --no-verify --verify\n '\n \n+test_expect_success 'git pull --rebase --autostash succeeds on ff' '\n+\ttest_when_finished \"rm -fr src dst actual\" &&\n+\tgit init src &&\n+\ttest_commit -C src \"initial\" file \"content\" &&\n+\tgit clone src dst &&\n+\ttest_commit -C src --printf \"more_content\" file \"more content\\ncontent\\n\" &&\n+\techo \"dirty\" >>dst/file &&\n+\tgit -C dst pull --rebase --autostash >actual 2>&1 &&\n+\tgrep -q \"Fast-forward\" actual &&\n+\tgrep -q \"Applied autostash.\" actual\n+'\n+\n+test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' '\n+\ttest_when_finished \"rm -fr src dst actual\" &&\n+\tgit init src &&\n+\ttest_commit -C src \"initial\" file \"content\" &&\n+\tgit clone src dst &&\n+\ttest_commit -C src --printf \"more_content\" file \"more content\\ncontent\\n\" &&\n+\techo \"dirty\" >>dst/file &&\n+\ttest_config -C dst rebase.autostash true &&\n+\tgit -C dst pull --rebase  >actual 2>&1 &&\n+\tgrep -q \"Fast-forward\" actual &&\n+\tgrep -q \"Applied autostash.\" actual\n+'\n+\n+test_expect_success 'git pull --rebase --autostash succeeds on non-ff' '\n+\ttest_when_finished \"rm -fr src dst actual\" &&\n+\tgit init src &&\n+\ttest_commit -C src \"initial\" file \"content\" &&\n+\tgit clone src dst &&\n+\ttest_commit -C src --printf \"src_content\" file \"src content\\ncontent\\n\" &&\n+\ttest_commit -C dst --append \"dst_content\" file \"dst content\" &&\n+\techo \"dirty\" >>dst/file &&\n+\tgit -C dst pull --rebase --autostash >actual 2>&1 &&\n+\tgrep -q \"Successfully rebased and updated refs/heads/main.\" actual &&\n+\tgrep -q \"Applied autostash.\" actual\n+'\n+\n+test_expect_success 'git pull --rebase with rebase.autostash succeeds on non-ff' '\n+\ttest_when_finished \"rm -fr src dst actual\" &&\n+\tgit init src &&\n+\ttest_commit -C src \"initial\" file \"content\" &&\n+\tgit clone src dst &&\n+\ttest_commit -C src --printf \"src_content\" file \"src content\\ncontent\\n\" &&\n+\ttest_commit -C dst --append \"dst_content\" file \"dst content\" &&\n+\techo \"dirty\" >>dst/file &&\n+\ttest_config -C dst rebase.autostash true &&\n+\tgit -C dst pull --rebase >actual 2>&1 &&\n+\tgrep -q \"Successfully rebased and updated refs/heads/main.\" actual &&\n+\tgrep -q \"Applied autostash.\" actual\n+'\n+\n test_done\n-- \n2.34.1\n\n"},{"id":"445409","messageId":"1240d0cd-230d-8a80-2250-37336b834834@iee.email","threadId":"57173","inReplyTo":"9749fa2c-b08d-c08b-ce43-041d13852d02@web.de","subject":"Re: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2022-01-04T12:59:34Z","receivedAt":"2022-01-04T12:59:37Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 03/01/2022 18:08, Tilman Vogel wrote:\n> Hi git-people,\n>\n> I ran into strange behavior when having rebase.autostash enabled and\n> doing a git pull --rebase:\n>\n>> git config rebase.autostash true\n>> git pull --rebase\n> Updating cd9ff8a..f3c9840\n> error: Your local changes to the following files would be overwritten by\n> merge:\n>         content\n> Please commit your changes or stash them before you merge.\n> Aborting\n>\n> Confusingly, this fixes the issue:\n>\n>> git config merge.autostash true\n>> git pull --rebase\n> Updating cd9ff8a..f3c9840\n> Created autostash: c615fda\n> Fast-forward\n>  content | 1 +\n>  1 file changed, 1 insertion(+)\n> Applied autostash.\n>\n> Leaving me wonder why merge config options fix rebase behavior.\n>\n> So, in order to make it easier to check the problem, I added some\n> test-cases to the git test-suite. Please see the attached patch.\n>\n> Or here:\n> https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705\n>\n> I did not try to find the root-cause as I am not experienced with the\n> code-base but if there are questions, let me know.\n\nWhich version are you running?\n\nThere was a problem in 2.33.1 as per thread discussion:\n https://lore.kernel.org/git/YYFEE%2F2g3SiM04zx@hades.panopticon/\n (I'd searched the logs for \".autostash true\")\n\nDoes that provide any guidance?\n--\nPhilip\n\n"},{"id":"445442","messageId":"cb8d6e8a-aaca-c2eb-6cc8-5c4ad33adfdb@gmail.com","threadId":"57173","inReplyTo":"1240d0cd-230d-8a80-2250-37336b834834@iee.email","subject":"Re: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2022-01-04T18:03:08Z","receivedAt":"2022-01-04T18:03:12Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Tilman,\n\nLe 2022-01-04 à 07:59, Philip Oakley a écrit :\n> On 03/01/2022 18:08, Tilman Vogel wrote:\n>> Hi git-people,\n>>\n>> I ran into strange behavior when having rebase.autostash enabled and\n>> doing a git pull --rebase:\n>>\n>>> git config rebase.autostash true\n>>> git pull --rebase\n>> Updating cd9ff8a..f3c9840\n>> error: Your local changes to the following files would be overwritten by\n>> merge:\n>>          content\n>> Please commit your changes or stash them before you merge.\n>> Aborting\n>>\n>> Confusingly, this fixes the issue:\n>>\n>>> git config merge.autostash true\n>>> git pull --rebase\n>> Updating cd9ff8a..f3c9840\n>> Created autostash: c615fda\n>> Fast-forward\n>>   content | 1 +\n>>   1 file changed, 1 insertion(+)\n>> Applied autostash.\n>>\n>> Leaving me wonder why merge config options fix rebase behavior.\n>>\n>> So, in order to make it easier to check the problem, I added some\n>> test-cases to the git test-suite. Please see the attached patch.\n\nThanks, this really makes it easier to bisect the issue.\n\n>>\n>> Or here:\n>> https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705\n>>\n>> I did not try to find the root-cause as I am not experienced with the\n>> code-base but if there are questions, let me know.\n> \n> Which version are you running?\n> \n\nThat's a good info to include indeed. I'm guessing you are using v2.34.1 as that's the version\nindicated at the bottom of your attached patch. I can replicate the behaviour on my side on 2.34.1.\nI did not bisect manually but I'm pretty sure it's a regression caused by 340062243a (pull: cleanup autostash\ncheck, 2021-06-17) (author CC'ed). I checked that the parent of that commit passes all 4 of your added tests, provided\nthis is squashed in:\n\ndiff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh\nindex 4046a74cad..5ad19b1028 100755\n--- a/t/t5521-pull-options.sh\n+++ b/t/t5521-pull-options.sh\n@@ -260,7 +260,6 @@ test_expect_success 'git pull --rebase --autostash succeeds on ff' '\n  \ttest_commit -C src --printf \"more_content\" file \"more content\\ncontent\\n\" &&\n  \techo \"dirty\" >>dst/file &&\n  \tgit -C dst pull --rebase --autostash >actual 2>&1 &&\n-\tgrep -q \"Fast-forward\" actual &&\n  \tgrep -q \"Applied autostash.\" actual\n  '\n  \n@@ -273,7 +272,6 @@ test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' '\n  \techo \"dirty\" >>dst/file &&\n  \ttest_config -C dst rebase.autostash true &&\n  \tgit -C dst pull --rebase  >actual 2>&1 &&\n-\tgrep -q \"Fast-forward\" actual &&\n  \tgrep -q \"Applied autostash.\" actual\n  '\n\nAfter that commit, in case of fast-forward, 'git pull --rebase --autostash' delegates the fast-forward\noperation to 'git merge' under the hood, which was not the case before. The '--autostash' flag seems\nto be forwarded correctly to that 'git merge' invocation, but the config 'rebase.autostash' seems to not\nbe passed along.\n\nI did not yet look into why in the code itself. That does explain however why 'merge.autostash' makes it\nwork - the 'git merge' invocation does check its own config, and if merge.autostash is there the autostash\nbehaviour is activated.\n\nPhilippe.\n\n\n"},{"id":"445454","messageId":"507d156f-9135-229e-423d-a8ab68bfa9b7@gmail.com","threadId":"57173","inReplyTo":"cb8d6e8a-aaca-c2eb-6cc8-5c4ad33adfdb@gmail.com","subject":"Re: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2022-01-04T18:29:27Z","receivedAt":"2022-01-04T18:30:30Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi again,\n\nLe 2022-01-04 à 13:03, Philippe Blain a écrit :\n> Hi Tilman,\n> \n> Le 2022-01-04 à 07:59, Philip Oakley a écrit :\n>> On 03/01/2022 18:08, Tilman Vogel wrote:\n>>> Hi git-people,\n>>>\n>>> I ran into strange behavior when having rebase.autostash enabled and\n>>> doing a git pull --rebase:\n>>>\n>>>> git config rebase.autostash true\n>>>> git pull --rebase\n>>> Updating cd9ff8a..f3c9840\n>>> error: Your local changes to the following files would be overwritten by\n>>> merge:\n>>>          content\n>>> Please commit your changes or stash them before you merge.\n>>> Aborting\n>>>\n>>> Confusingly, this fixes the issue:\n>>>\n>>>> git config merge.autostash true\n>>>> git pull --rebase\n>>> Updating cd9ff8a..f3c9840\n>>> Created autostash: c615fda\n>>> Fast-forward\n>>>   content | 1 +\n>>>   1 file changed, 1 insertion(+)\n>>> Applied autostash.\n>>>\n>>> Leaving me wonder why merge config options fix rebase behavior.\n>>>\n>>> So, in order to make it easier to check the problem, I added some\n>>> test-cases to the git test-suite. Please see the attached patch.\n> \n> Thanks, this really makes it easier to bisect the issue.\n> \n>>>\n>>> Or here:\n>>> https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705\n>>>\n>>> I did not try to find the root-cause as I am not experienced with the\n>>> code-base but if there are questions, let me know.\n>>\n>> Which version are you running?\n>>\n> \n> That's a good info to include indeed. I'm guessing you are using v2.34.1 as that's the version\n> indicated at the bottom of your attached patch. I can replicate the behaviour on my side on 2.34.1.\n> I did not bisect manually but I'm pretty sure it's a regression caused by 340062243a (pull: cleanup autostash\n> check, 2021-06-17) (author CC'ed). I checked that the parent of that commit passes all 4 of your added tests, provided\n> this is squashed in:\n> \n> diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh\n> index 4046a74cad..5ad19b1028 100755\n> --- a/t/t5521-pull-options.sh\n> +++ b/t/t5521-pull-options.sh\n> @@ -260,7 +260,6 @@ test_expect_success 'git pull --rebase --autostash succeeds on ff' '\n>       test_commit -C src --printf \"more_content\" file \"more content\\ncontent\\n\" &&\n>       echo \"dirty\" >>dst/file &&\n>       git -C dst pull --rebase --autostash >actual 2>&1 &&\n> -    grep -q \"Fast-forward\" actual &&\n>       grep -q \"Applied autostash.\" actual\n>   '\n> \n> @@ -273,7 +272,6 @@ test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' '\n>       echo \"dirty\" >>dst/file &&\n>       test_config -C dst rebase.autostash true &&\n>       git -C dst pull --rebase  >actual 2>&1 &&\n> -    grep -q \"Fast-forward\" actual &&\n>       grep -q \"Applied autostash.\" actual\n>   '\n> \n> After that commit, in case of fast-forward, 'git pull --rebase --autostash' delegates the fast-forward\n> operation to 'git merge' under the hood, which was not the case before. The '--autostash' flag seems\n> to be forwarded correctly to that 'git merge' invocation, but the config 'rebase.autostash' seems to not\n> be passed along.\n> \n> I did not yet look into why in the code itself\n\nAfter looking at it a bit, this seems to fix the bug:\n\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 1cfaf9f343..0b206bf1d5 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -87,6 +87,7 @@ static char *opt_verify_signatures;\n  static char *opt_verify;\n  static int opt_autostash = -1;\n  static int config_autostash;\n+static int autostash = -1;\n  static int check_trust_level = 1;\n  static struct strvec opt_strategies = STRVEC_INIT;\n  static struct strvec opt_strategy_opts = STRVEC_INIT;\n@@ -687,9 +688,9 @@ static int run_merge(void)\n  \tstrvec_pushv(&args, opt_strategy_opts.v);\n  \tif (opt_gpg_sign)\n  \t\tstrvec_push(&args, opt_gpg_sign);\n-\tif (opt_autostash == 0)\n+\tif (autostash == 0)\n  \t\tstrvec_push(&args, \"--no-autostash\");\n-\telse if (opt_autostash == 1)\n+\telse if (autostash == 1)\n  \t\tstrvec_push(&args, \"--autostash\");\n  \tif (opt_allow_unrelated_histories > 0)\n  \t\tstrvec_push(&args, \"--allow-unrelated-histories\");\n@@ -1036,7 +1037,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n  \t\toidclr(&orig_head);\n  \n  \tif (opt_rebase) {\n-\t\tint autostash = config_autostash;\n+\t\tautostash = config_autostash;\n  \t\tif (opt_autostash != -1)\n  \t\t\tautostash = opt_autostash;\n\n\nIf nobody beats me to it (if that's the case, be my guest !), I'll try to submit a proper patch later\ntoday or this week.\n\nIn case anybody needs it:\n\nSigned-off by: Philippe Blain <levraiphilippeblain@gmail.com>\n\n\nCheers,\n\nPhilippe.\n  \n\n"},{"id":"445474","messageId":"CAAbQbbCtFnbfTHnMdY_xi1CN4NyppShZdVhgO73YMubgDjwB-A@mail.gmail.com","threadId":"57173","inReplyTo":"cb8d6e8a-aaca-c2eb-6cc8-5c4ad33adfdb@gmail.com","subject":"Re: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","fromName":"Tilman Vogel","fromEmail":"tilman.vogel@web.de","sentAt":"2022-01-04T21:03:38Z","receivedAt":"2022-01-04T21:03:51Z","isPatch":false,"sender":{"key":"tilman.vogel@web.de","avatar":"https://avatars.githubusercontent.com/u/349303?v=4"},"body":"Oh, please excuse my lack of providing the version info: I discovered\nthe behaviour on 2.34.1 as shipped by current openSUSE Tumbleweed.\nThen, I worked on-top of current git master (2ae0a9cb).\n\nRegards and thanks for investigating and fixing this so quickly!\n\nTilman\n\n\nAm Di., 4. Jan. 2022 um 19:03 Uhr schrieb Philippe Blain\n<levraiphilippeblain@gmail.com>:\n>\n> Hi Tilman,\n>\n> Le 2022-01-04 à 07:59, Philip Oakley a écrit :\n> > On 03/01/2022 18:08, Tilman Vogel wrote:\n> >> Hi git-people,\n> >>\n> >> I ran into strange behavior when having rebase.autostash enabled and\n> >> doing a git pull --rebase:\n> >>\n> >>> git config rebase.autostash true\n> >>> git pull --rebase\n> >> Updating cd9ff8a..f3c9840\n> >> error: Your local changes to the following files would be overwritten by\n> >> merge:\n> >>          content\n> >> Please commit your changes or stash them before you merge.\n> >> Aborting\n> >>\n> >> Confusingly, this fixes the issue:\n> >>\n> >>> git config merge.autostash true\n> >>> git pull --rebase\n> >> Updating cd9ff8a..f3c9840\n> >> Created autostash: c615fda\n> >> Fast-forward\n> >>   content | 1 +\n> >>   1 file changed, 1 insertion(+)\n> >> Applied autostash.\n> >>\n> >> Leaving me wonder why merge config options fix rebase behavior.\n> >>\n> >> So, in order to make it easier to check the problem, I added some\n> >> test-cases to the git test-suite. Please see the attached patch.\n>\n> Thanks, this really makes it easier to bisect the issue.\n>\n> >>\n> >> Or here:\n> >> https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705\n> >>\n> >> I did not try to find the root-cause as I am not experienced with the\n> >> code-base but if there are questions, let me know.\n> >\n> > Which version are you running?\n> >\n>\n> That's a good info to include indeed. I'm guessing you are using v2.34.1 as that's the version\n> indicated at the bottom of your attached patch. I can replicate the behaviour on my side on 2.34.1.\n> I did not bisect manually but I'm pretty sure it's a regression caused by 340062243a (pull: cleanup autostash\n> check, 2021-06-17) (author CC'ed). I checked that the parent of that commit passes all 4 of your added tests, provided\n> this is squashed in:\n>\n> diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh\n> index 4046a74cad..5ad19b1028 100755\n> --- a/t/t5521-pull-options.sh\n> +++ b/t/t5521-pull-options.sh\n> @@ -260,7 +260,6 @@ test_expect_success 'git pull --rebase --autostash succeeds on ff' '\n>         test_commit -C src --printf \"more_content\" file \"more content\\ncontent\\n\" &&\n>         echo \"dirty\" >>dst/file &&\n>         git -C dst pull --rebase --autostash >actual 2>&1 &&\n> -       grep -q \"Fast-forward\" actual &&\n>         grep -q \"Applied autostash.\" actual\n>   '\n>\n> @@ -273,7 +272,6 @@ test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' '\n>         echo \"dirty\" >>dst/file &&\n>         test_config -C dst rebase.autostash true &&\n>         git -C dst pull --rebase  >actual 2>&1 &&\n> -       grep -q \"Fast-forward\" actual &&\n>         grep -q \"Applied autostash.\" actual\n>   '\n>\n> After that commit, in case of fast-forward, 'git pull --rebase --autostash' delegates the fast-forward\n> operation to 'git merge' under the hood, which was not the case before. The '--autostash' flag seems\n> to be forwarded correctly to that 'git merge' invocation, but the config 'rebase.autostash' seems to not\n> be passed along.\n>\n> I did not yet look into why in the code itself. That does explain however why 'merge.autostash' makes it\n> work - the 'git merge' invocation does check its own config, and if merge.autostash is there the autostash\n> behaviour is activated.\n>\n> Philippe.\n>\n>\n"},{"id":"445492","messageId":"3d56ab46-bb65-59d0-8b4d-c0e5807814be@gmail.com","threadId":"57173","inReplyTo":"BB019E6A-90ED-4D5A-A756-FA8700897DE7@gmail.com","subject":"Re: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2022-01-04T23:20:27Z","receivedAt":"2022-01-04T23:20:31Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi John,\n\nLe 2022-01-04 à 13:49, John Cai a écrit :\n> \n>> On Jan 4, 2022, at 1:29 PM, Philippe Blain <levraiphilippeblain@gmail.com <mailto:levraiphilippeblain@gmail.com>> wrote:\n>>\n>> Hi again,\n>>\n>> Le 2022-01-04 à 13:03, Philippe Blain a écrit :\n>>> Hi Tilman,\n>>> Le 2022-01-04 à 07:59, Philip Oakley a écrit :\n>>>> On 03/01/2022 18:08, Tilman Vogel wrote:\n>>>>> Hi git-people,\n>>>>>\n>>>>> I ran into strange behavior when having rebase.autostash enabled and\n>>>>> doing a git pull --rebase:\n>>>>>\n>>>>>> git config rebase.autostash true\n>>>>>> git pull --rebase\n>>>>> Updating cd9ff8a..f3c9840\n>>>>> error: Your local changes to the following files would be overwritten by\n>>>>> merge:\n>>>>>          content\n>>>>> Please commit your changes or stash them before you merge.\n>>>>> Aborting\n>>>>>\n>>>>> Confusingly, this fixes the issue:\n>>>>>\n>>>>>> git config merge.autostash true\n>>>>>> git pull --rebase\n>>>>> Updating cd9ff8a..f3c9840\n>>>>> Created autostash: c615fda\n>>>>> Fast-forward\n>>>>>   content | 1 +\n>>>>>   1 file changed, 1 insertion(+)\n>>>>> Applied autostash.\n>>>>>\n>>>>> Leaving me wonder why merge config options fix rebase behavior.\n>>>>>\n>>>>> So, in order to make it easier to check the problem, I added some\n>>>>> test-cases to the git test-suite. Please see the attached patch.\n>>> Thanks, this really makes it easier to bisect the issue.\n>>>>>\n>>>>> Or here:\n>>>>> https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705 <https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705>\n>>>>>\n>>>>> I did not try to find the root-cause as I am not experienced with the\n>>>>> code-base but if there are questions, let me know.\n>>>>\n>>>> Which version are you running?\n>>>>\n>>> That's a good info to include indeed. I'm guessing you are using v2.34.1 as that's the version\n>>> indicated at the bottom of your attached patch. I can replicate the behaviour on my side on 2.34.1.\n>>> I did not bisect manually but I'm pretty sure it's a regression caused by 340062243a (pull: cleanup autostash\n>>> check, 2021-06-17) (author CC'ed). I checked that the parent of that commit passes all 4 of your added tests, provided\n>>> this is squashed in:\n>>> diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh\n>>> index 4046a74cad..5ad19b1028 100755\n>>> --- a/t/t5521-pull-options.sh\n>>> +++ b/t/t5521-pull-options.sh\n>>> @@ -260,7 +260,6 @@ test_expect_success 'git pull --rebase --autostash succeeds on ff' '\n>>>      test_commit -C src --printf \"more_content\" file \"more content\\ncontent\\n\" &&\n>>>      echo \"dirty\" >>dst/file &&\n>>>      git -C dst pull --rebase --autostash >actual 2>&1 &&\n>>> -    grep -q \"Fast-forward\" actual &&\n>>>      grep -q \"Applied autostash.\" actual\n>>>  '\n>>> @@ -273,7 +272,6 @@ test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' '\n>>>      echo \"dirty\" >>dst/file &&\n>>>      test_config -C dst rebase.autostash true &&\n>>>      git -C dst pull --rebase  >actual 2>&1 &&\n>>> -    grep -q \"Fast-forward\" actual &&\n>>>      grep -q \"Applied autostash.\" actual\n>>>  '\n>>> After that commit, in case of fast-forward, 'git pull --rebase --autostash' delegates the fast-forward\n>>> operation to 'git merge' under the hood, which was not the case before. The '--autostash' flag seems\n>>> to be forwarded correctly to that 'git merge' invocation, but the config 'rebase.autostash' seems to not\n>>> be passed along.\n>>> I did not yet look into why in the code itself\n>>\n>> After looking at it a bit, this seems to fix the bug:\n>>\n>> diff --git a/builtin/pull.c b/builtin/pull.c\n>> index 1cfaf9f343..0b206bf1d5 100644\n>> --- a/builtin/pull.c\n>> +++ b/builtin/pull.c\n>> @@ -87,6 +87,7 @@ static char *opt_verify_signatures;\n>> static char *opt_verify;\n>> static int opt_autostash = -1;\n>> static int config_autostash;\n>> +static int autostash = -1;\n>> static int check_trust_level = 1;\n>> static struct strvec opt_strategies = STRVEC_INIT;\n>> static struct strvec opt_strategy_opts = STRVEC_INIT;\n>> @@ -687,9 +688,9 @@ static int run_merge(void)\n>> strvec_pushv(&args, opt_strategy_opts.v);\n>> if (opt_gpg_sign)\n>> strvec_push(&args, opt_gpg_sign);\n>> -if (opt_autostash == 0)\n>> +if (autostash == 0)\n>> strvec_push(&args, \"--no-autostash\");\n>> -else if (opt_autostash == 1)\n>> +else if (autostash == 1)\n>> strvec_push(&args, \"--autostash\");\n>> if (opt_allow_unrelated_histories > 0)\n>> strvec_push(&args, \"--allow-unrelated-histories\");\n>> @@ -1036,7 +1037,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)\n>> oidclr(&orig_head);\n>> if (opt_rebase) {\n>> -int autostash = config_autostash;\n>> +autostash = config_autostash;\n>> if (opt_autostash != -1)\n>> autostash = opt_autostash;\n\nIt seems your email client is messing up whitespace (I'm guessing you might be\nusing the Gmail web UI, it's known to have this problem), you should try to\nfind a email client that does not have this behaviour :)\n\n>>\n>>\n>> If nobody beats me to it (if that's the case, be my guest !), I'll try to submit a proper patch later\n>> today or this week.\n> \n> (Resending due to my previous message containing HTML and being rejected by the mail server)\n\nIt seems this here email did not either reach the mailing list archive.\n\n> \n> Hi Philippe,\n> \n> Looks like we were working on this in parallel :) I have a PR I was about to submit as a patch through GGG: github.com/git/git/pull/1179 <http://github.com/git/git/pull/1179>\n> \n> My fix is very similar to yours. I can add you ad a co-author if you’d like?\n> \n\nThanks for asking. I saw you sent your patch at [1] with a \"Co-authored-by\" trailer.\nI would have prefered that you wait for my approbation before adding that \"Co-authored-by\",\nsince the code you are adding is different than what I posted above.\n\nI'll comment some more on your patch there.\n\nCheers,\n\nPhilippe.\n\n[1] https://lore.kernel.org/git/20220104214522.10692-1-johncai86@gmail.com/T/#t\n"}]}