From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Elijah Newren <newren@gmail.com>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v2 13/13] pull: improve --rebase and pull.rebase interaction
Date: Fri, 18 Dec 2020 15:10:26 -0600 [thread overview]
Message-ID: <20201218211026.1937168-14-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20201218211026.1937168-1-felipe.contreras@gmail.com>
Currently --rebase without argument overrides pull.rebase:
git config pull.rebase merges
git pull --rebase
Up until now this hasn't been a big issue, since user has not been
forced to specify a merge, or a rebase. But with the introduction of
--merge and pull.mode, the user could in theory have the following
configuration:
git config pull.mode merge
git config pull.rebase merges
In such case, the user would expect:
git pull --rebase
To be the same as:
git pull --rebase=merges
If the user wants to override the configuration, she can do:
git pull --rebase=true
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
builtin/pull.c | 10 ++++++++--
t/t5520-pull.sh | 10 ++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/builtin/pull.c b/builtin/pull.c
index ad8afabe9b..4e8e9d85a2 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -68,8 +68,14 @@ static int parse_opt_rebase(const struct option *opt, const char *arg, int unset
if (arg)
*value = parse_config_rebase("--rebase", arg, 0);
- else
- *value = unset ? REBASE_FALSE : REBASE_TRUE;
+ else {
+ if (!unset) {
+ /* --rebase shouldn't override pull.rebase=merges (and others) */
+ if (*value < REBASE_TRUE)
+ *value = REBASE_TRUE;
+ } else
+ *value = REBASE_FALSE;
+ }
if (*value > 0)
mode = *value >= REBASE_TRUE ? PULL_MODE_REBASE : PULL_MODE_MERGE;
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 45d818065f..d0f5722eab 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -595,6 +595,16 @@ test_expect_success REBASE_P \
test_cmp_rev HEAD^2 keep-merge
'
+test_expect_success REBASE_P \
+ 'pull.rebase=preserve interacts correctly with pull.mode and --rebase' '
+ git reset --hard before-preserve-rebase &&
+ test_config pull.mode merge &&
+ test_config pull.rebase preserve &&
+ git pull --rebase . copy &&
+ test_cmp_rev HEAD^^ copy &&
+ test_cmp_rev HEAD^2 keep-merge
+'
+
test_expect_success 'pull.rebase=interactive' '
write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
echo I was here >fake.out &&
--
2.30.0.rc0
prev parent reply other threads:[~2020-12-18 21:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-18 21:10 [PATCH v2 00/13] pull: pull mode part 2 Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 01/13] doc: pull: explain what is a fast-forward Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 02/13] pull: improve default warning Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 03/13] pull: cleanup autostash check Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 04/13] pull: trivial cleanup Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 05/13] pull: trivial whitespace style fix Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 06/13] pull: introduce --merge option Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 07/13] rebase: add REBASE_DEFAULT Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 08/13] pull: move configurations fetches Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 09/13] pull: show warning with --ff options Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 10/13] pull: add pull.mode Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 11/13] pull: add pull.mode=fast-forward Felipe Contreras
2020-12-18 21:10 ` [PATCH v2 12/13] pull: reorganize mode conditionals Felipe Contreras
2020-12-18 21:10 ` Felipe Contreras [this message]
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=20201218211026.1937168-14-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
/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).