From: Tilman Vogel <tilman.vogel@web.de>
To: git@vger.kernel.org
Subject: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding
Date: Mon, 3 Jan 2022 19:08:21 +0100 [thread overview]
Message-ID: <9749fa2c-b08d-c08b-ce43-041d13852d02@web.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]
Hi git-people,
I ran into strange behavior when having rebase.autostash enabled and
doing a git pull --rebase:
> git config rebase.autostash true
> git pull --rebase
Updating cd9ff8a..f3c9840
error: Your local changes to the following files would be overwritten by
merge:
content
Please commit your changes or stash them before you merge.
Aborting
Confusingly, this fixes the issue:
> git config merge.autostash true
> git pull --rebase
Updating cd9ff8a..f3c9840
Created autostash: c615fda
Fast-forward
content | 1 +
1 file changed, 1 insertion(+)
Applied autostash.
Leaving me wonder why merge config options fix rebase behavior.
So, in order to make it easier to check the problem, I added some
test-cases to the git test-suite. Please see the attached patch.
Or here:
https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705
I did not try to find the root-cause as I am not experienced with the
code-base but if there are questions, let me know.
Best regards,
Tilman
[-- Attachment #2: git-pull-rebase-autostash-problem.patch --]
[-- Type: text/x-patch, Size: 3303 bytes --]
From bc941f9357518a34cfa11788dfb8e7fa7f711705 Mon Sep 17 00:00:00 2001
From: Tilman Vogel <tilman.vogel@web.de>
Date: Mon, 3 Jan 2022 18:31:59 +0100
Subject: [PATCH] t5521: Show inconsistent rebase behavior (--autostash vs.
rebase.autostash)
When pull --rebase can be done as a fast-forward, the rebase.autostash
config is neglected such that the second test-case added in this commit
will fail to autostash and succeed.
In fact, setting merge.autostash as a workaround would cause autostash to
be done.
The other three test-cases added in this commit document that autostashing
works as expected when either requested explicitly with --autostash or when
pull --rebase cannot be done as a fast-forward.
Signed-off-by: Tilman Vogel <tilman.vogel@web.de>
---
t/t5521-pull-options.sh | 52 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 66cfcb09c5..4046a74cad 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -252,4 +252,56 @@ test_expect_success 'git pull --no-verify --verify passed to merge' '
test_must_fail git -C dst pull --no-ff --no-verify --verify
'
+test_expect_success 'git pull --rebase --autostash succeeds on ff' '
+ test_when_finished "rm -fr src dst actual" &&
+ git init src &&
+ test_commit -C src "initial" file "content" &&
+ git clone src dst &&
+ test_commit -C src --printf "more_content" file "more content\ncontent\n" &&
+ echo "dirty" >>dst/file &&
+ git -C dst pull --rebase --autostash >actual 2>&1 &&
+ grep -q "Fast-forward" actual &&
+ grep -q "Applied autostash." actual
+'
+
+test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' '
+ test_when_finished "rm -fr src dst actual" &&
+ git init src &&
+ test_commit -C src "initial" file "content" &&
+ git clone src dst &&
+ test_commit -C src --printf "more_content" file "more content\ncontent\n" &&
+ echo "dirty" >>dst/file &&
+ test_config -C dst rebase.autostash true &&
+ git -C dst pull --rebase >actual 2>&1 &&
+ grep -q "Fast-forward" actual &&
+ grep -q "Applied autostash." actual
+'
+
+test_expect_success 'git pull --rebase --autostash succeeds on non-ff' '
+ test_when_finished "rm -fr src dst actual" &&
+ git init src &&
+ test_commit -C src "initial" file "content" &&
+ git clone src dst &&
+ test_commit -C src --printf "src_content" file "src content\ncontent\n" &&
+ test_commit -C dst --append "dst_content" file "dst content" &&
+ echo "dirty" >>dst/file &&
+ git -C dst pull --rebase --autostash >actual 2>&1 &&
+ grep -q "Successfully rebased and updated refs/heads/main." actual &&
+ grep -q "Applied autostash." actual
+'
+
+test_expect_success 'git pull --rebase with rebase.autostash succeeds on non-ff' '
+ test_when_finished "rm -fr src dst actual" &&
+ git init src &&
+ test_commit -C src "initial" file "content" &&
+ git clone src dst &&
+ test_commit -C src --printf "src_content" file "src content\ncontent\n" &&
+ test_commit -C dst --append "dst_content" file "dst content" &&
+ echo "dirty" >>dst/file &&
+ test_config -C dst rebase.autostash true &&
+ git -C dst pull --rebase >actual 2>&1 &&
+ grep -q "Successfully rebased and updated refs/heads/main." actual &&
+ grep -q "Applied autostash." actual
+'
+
test_done
--
2.34.1
next reply other threads:[~2022-01-03 18:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-03 18:08 Tilman Vogel [this message]
2022-01-04 12:59 ` [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding Philip Oakley
2022-01-04 18:03 ` Philippe Blain
2022-01-04 18:29 ` Philippe Blain
[not found] ` <BB019E6A-90ED-4D5A-A756-FA8700897DE7@gmail.com>
2022-01-04 23:20 ` Philippe Blain
2022-01-04 21:03 ` Tilman Vogel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9749fa2c-b08d-c08b-ce43-041d13852d02@web.de \
--to=tilman.vogel@web.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).