From: John Cai <johncai86@gmail.com>
To: git@vger.kernel.org
Cc: levraiphilippeblain@gmail.com, phillip.wood123@gmail.com,
John Cai <johncai86@gmail.com>,
"Tilman Vogel" <tilman.vogel@web.de>,
"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v3] builtin/pull.c: teach run_merge() to honor rebase.autostash config
Date: Thu, 6 Jan 2022 10:02:26 -0500 [thread overview]
Message-ID: <20220106150226.77458-1-johncai86@gmail.com> (raw)
On a git pull --rebase, if fast forward is possible we run merge.
However, merge will not honor rebase.autostash if it is configured. This
has the unfortunate result of
$ git config rebase.autostash true
$ git pull --rebase
to ignore the rebase.autostash value.
Allow run_merge() to honor rebase.autostash by passing in
config_autostash if --autostash or --no-autostash flags are not
explicitly set.
Reported-by: "Tilman Vogel" <tilman.vogel@web.de>
Co-authored-by: "Junio C Hamano" <gitster@pobox.com>
Signed-off-by: "John Cai" <johncai86@gmail.com>
---
Notes:
Fix a bug that prevents git pull --rebase from honoring the rebase.autostash
config value.
Changes since V2:
- fixed Junio's email in trailer
Changes since V1:
- used simpler fix as proposed by Junio
- removed redundant test cases
builtin/pull.c | 9 ++++++++-
t/t5521-pull-options.sh | 12 ++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/builtin/pull.c b/builtin/pull.c
index 100cbf9fb8..8423e420ee 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -1133,7 +1133,14 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
die(_("cannot rebase with locally recorded submodule modifications"));
if (can_ff) {
- /* we can fast-forward this without invoking rebase */
+ /*
+ * We can fast-forward without invoking
+ * rebase, by calling run_merge(). But we
+ * have to allow rebase.autostash=true to kick
+ * in.
+ */
+ if (opt_autostash < 0)
+ opt_autostash = config_autostash;
opt_ff = "--ff-only";
ret = run_merge();
} else {
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 66cfcb09c5..66fac99d2b 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -252,4 +252,16 @@ 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_done
--
2.34.1
next reply other threads:[~2022-01-06 15:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 15:02 John Cai [this message]
2022-01-06 17:12 ` [PATCH v3] builtin/pull.c: teach run_merge() to honor rebase.autostash config Taylor Blau
2022-01-06 17:14 ` Taylor Blau
2022-01-06 18:31 ` Junio C Hamano
2022-01-06 19:36 ` Taylor Blau
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220106150226.77458-1-johncai86@gmail.com \
--to=johncai86@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=levraiphilippeblain@gmail.com \
--cc=phillip.wood123@gmail.com \
--cc=tilman.vogel@web.de \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.