From: "Alex Henrie via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Alex Henrie" <alexhenrie24@gmail.com>,
"Son Luong Ngoc" <sluongng@gmail.com>,
"Matthias Baumgarten" <matthias.baumgarten@aixigo.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Elijah Newren" <newren@gmail.com>,
"Felipe Contreras" <felipe.contreras@gmail.com>,
"Elijah Newren" <newren@gmail.com>,
"Alex Henrie" <alexhenrie24@gmail.com>
Subject: [PATCH v3 3/8] pull: abort if --ff-only is given and fast-forwarding is impossible
Date: Thu, 22 Jul 2021 05:04:45 +0000 [thread overview]
Message-ID: <c45cd2396664e915a1d962e6d131505df51b118e.1626930290.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1049.v3.git.git.1626930290.gitgitgadget@gmail.com>
From: Alex Henrie <alexhenrie24@gmail.com>
The warning about pulling without specifying how to reconcile divergent
branches says that after setting pull.rebase to true, --ff-only can
still be passed on the command line to require a fast-forward. Make that
actually work.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
[en: updated tests; note 3 fixes and 1 new failure]
Signed-off-by: Elijah Newren <newren@gmail.com>
---
advice.c | 5 +++++
advice.h | 1 +
builtin/merge.c | 2 +-
builtin/pull.c | 11 ++++++++---
t/t7601-merge-pull-config.sh | 10 +++++-----
5 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/advice.c b/advice.c
index 0b9c89c48ab..337e8f342bc 100644
--- a/advice.c
+++ b/advice.c
@@ -286,6 +286,11 @@ void NORETURN die_conclude_merge(void)
die(_("Exiting because of unfinished merge."));
}
+void NORETURN die_ff_impossible(void)
+{
+ die(_("Not possible to fast-forward, aborting."));
+}
+
void advise_on_updating_sparse_paths(struct string_list *pathspec_list)
{
struct string_list_item *item;
diff --git a/advice.h b/advice.h
index bd26c385d00..16240438387 100644
--- a/advice.h
+++ b/advice.h
@@ -95,6 +95,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...);
int error_resolve_conflict(const char *me);
void NORETURN die_resolve_conflict(const char *me);
void NORETURN die_conclude_merge(void);
+void NORETURN die_ff_impossible(void);
void advise_on_updating_sparse_paths(struct string_list *pathspec_list);
void detach_advice(const char *new_name);
diff --git a/builtin/merge.c b/builtin/merge.c
index a8a843b1f54..aa920ac524f 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1620,7 +1620,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}
if (fast_forward == FF_ONLY)
- die(_("Not possible to fast-forward, aborting."));
+ die_ff_impossible();
if (autostash)
create_autostash(the_repository,
diff --git a/builtin/pull.c b/builtin/pull.c
index 3e13f810843..d9796604825 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -1046,9 +1046,14 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]);
- if (rebase_unspecified && !opt_ff && !can_ff) {
- if (opt_verbosity >= 0)
- show_advice_pull_non_ff();
+ if (!can_ff) {
+ if (opt_ff) {
+ if (!strcmp(opt_ff, "--ff-only"))
+ die_ff_impossible();
+ } else {
+ if (rebase_unspecified && opt_verbosity >= 0)
+ show_advice_pull_non_ff();
+ }
}
if (opt_rebase) {
diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
index 21db1e9e14b..d1f621725ad 100755
--- a/t/t7601-merge-pull-config.sh
+++ b/t/t7601-merge-pull-config.sh
@@ -209,11 +209,11 @@ test_attempts_fast_forward () {
# Group 1: Interaction of --ff-only with --[no-]rebase
# (And related interaction of pull.ff=only with pull.rebase)
#
-test_expect_failure '--ff-only overrides --rebase' '
+test_expect_success '--ff-only overrides --rebase' '
test_attempts_fast_forward pull --rebase --ff-only
'
-test_expect_failure '--ff-only overrides --rebase even if first' '
+test_expect_success '--ff-only overrides --rebase even if first' '
test_attempts_fast_forward pull --ff-only --rebase
'
@@ -221,7 +221,7 @@ test_expect_success '--ff-only overrides --no-rebase' '
test_attempts_fast_forward pull --ff-only --no-rebase
'
-test_expect_failure 'pull.ff=only overrides pull.rebase=true' '
+test_expect_success 'pull.ff=only overrides pull.rebase=true' '
test_attempts_fast_forward -c pull.ff=only -c pull.rebase=true pull
'
@@ -252,7 +252,7 @@ test_expect_success 'pull.rebase=true overrides pull.ff=true' '
'
# Group 3: command line flags take precedence over config
-test_expect_failure '--ff-only takes precedence over pull.rebase=true' '
+test_expect_success '--ff-only takes precedence over pull.rebase=true' '
test_attempts_fast_forward -c pull.rebase=true pull --ff-only
'
@@ -264,7 +264,7 @@ test_expect_failure '--no-rebase takes precedence over pull.ff=only' '
test_falls_back_to_full_merge -c pull.ff=only pull --no-rebase
'
-test_expect_success '--rebase takes precedence over pull.ff=only' '
+test_expect_failure '--rebase takes precedence over pull.ff=only' '
test_does_rebase -c pull.ff=only pull --rebase
'
--
gitgitgadget
next prev parent reply other threads:[~2021-07-22 5:05 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-17 15:41 [PATCH 0/9] Handle pull option precedence Elijah Newren via GitGitGadget
2021-07-17 15:41 ` [PATCH 1/9] t7601: add relative precedence tests for merge and rebase flags/options Elijah Newren via GitGitGadget
2021-07-17 18:03 ` Felipe Contreras
2021-07-19 18:23 ` Junio C Hamano
2021-07-20 17:10 ` Elijah Newren
2021-07-20 18:22 ` Junio C Hamano
2021-07-20 20:29 ` Felipe Contreras
2021-07-17 15:41 ` [PATCH 2/9] t7601: add tests of interactions with multiple merge heads and config Elijah Newren via GitGitGadget
2021-07-17 18:04 ` Felipe Contreras
2021-07-20 23:11 ` Junio C Hamano
2021-07-21 0:45 ` Elijah Newren
2021-07-17 15:41 ` [PATCH 3/9] pull: abort if --ff-only is given and fast-forwarding is impossible Alex Henrie via GitGitGadget
2021-07-17 18:14 ` Felipe Contreras
2021-07-17 15:41 ` [PATCH 4/9] pull: since --ff-only overrides, handle it first Elijah Newren via GitGitGadget
2021-07-17 18:22 ` Felipe Contreras
2021-07-17 15:41 ` [PATCH 5/9] pull: ensure --rebase overrides ability to ff Elijah Newren via GitGitGadget
2021-07-17 18:25 ` Felipe Contreras
2021-07-20 23:35 ` Junio C Hamano
2021-07-21 0:14 ` Elijah Newren
2021-07-17 15:41 ` [PATCH 6/9] pull: make --rebase and --no-rebase override pull.ff=only Elijah Newren via GitGitGadget
2021-07-17 18:28 ` Felipe Contreras
2021-07-20 23:53 ` Junio C Hamano
2021-07-21 0:09 ` Felipe Contreras
2021-07-17 15:41 ` [PATCH 7/9] pull: abort by default when fast-forwarding is not possible Elijah Newren via GitGitGadget
2021-07-17 18:31 ` Felipe Contreras
2021-07-17 15:41 ` [PATCH 8/9] pull: update docs & code for option compatibility with rebasing Elijah Newren via GitGitGadget
2021-07-21 0:17 ` Junio C Hamano
2021-07-21 0:44 ` Elijah Newren
2021-07-21 1:25 ` Junio C Hamano
2021-07-17 15:41 ` [PATCH 9/9] pull: fix handling of multiple heads Elijah Newren via GitGitGadget
2021-07-17 18:39 ` [PATCH 0/9] Handle pull option precedence Felipe Contreras
2021-07-21 1:42 ` [PATCH v2 0/8] " Elijah Newren via GitGitGadget
2021-07-21 1:42 ` [PATCH v2 1/8] t7601: test interaction of merge/rebase/fast-forward flags and options Elijah Newren via GitGitGadget
2021-07-21 12:24 ` Felipe Contreras
2021-07-21 1:42 ` [PATCH v2 2/8] t7601: add tests of interactions with multiple merge heads and config Elijah Newren via GitGitGadget
2021-07-21 1:42 ` [PATCH v2 3/8] pull: abort if --ff-only is given and fast-forwarding is impossible Alex Henrie via GitGitGadget
2021-07-21 12:25 ` Felipe Contreras
2021-07-21 1:42 ` [PATCH v2 4/8] pull: since --ff-only overrides, handle it first Elijah Newren via GitGitGadget
2021-07-21 19:18 ` Matthias Baumgarten
2021-07-21 21:18 ` Felipe Contreras
2021-07-21 20:18 ` Junio C Hamano
2021-07-22 3:42 ` Elijah Newren
2021-07-21 1:42 ` [PATCH v2 5/8] pull: make --rebase and --no-rebase override pull.ff=only Elijah Newren via GitGitGadget
2021-07-21 12:26 ` Felipe Contreras
2021-07-21 1:42 ` [PATCH v2 6/8] pull: abort by default when fast-forwarding is not possible Elijah Newren via GitGitGadget
2021-07-21 12:27 ` Felipe Contreras
2021-07-21 1:42 ` [PATCH v2 7/8] pull: update docs & code for option compatibility with rebasing Elijah Newren via GitGitGadget
2021-07-21 1:42 ` [PATCH v2 8/8] pull: fix handling of multiple heads Elijah Newren via GitGitGadget
2021-07-21 12:15 ` [PATCH v2 0/8] Handle pull option precedence Felipe Contreras
2021-07-22 5:04 ` [PATCH v3 " Elijah Newren via GitGitGadget
2021-07-22 5:04 ` [PATCH v3 1/8] t7601: test interaction of merge/rebase/fast-forward flags and options Elijah Newren via GitGitGadget
2021-07-22 5:04 ` [PATCH v3 2/8] t7601: add tests of interactions with multiple merge heads and config Elijah Newren via GitGitGadget
2021-07-22 5:04 ` Alex Henrie via GitGitGadget [this message]
2021-07-22 5:04 ` [PATCH v3 4/8] pull: since --ff-only overrides, handle it first Elijah Newren via GitGitGadget
2021-07-22 5:04 ` [PATCH v3 5/8] pull: make --rebase and --no-rebase override pull.ff=only Elijah Newren via GitGitGadget
2021-07-22 5:04 ` [PATCH v3 6/8] pull: abort by default when fast-forwarding is not possible Elijah Newren via GitGitGadget
2021-07-22 5:04 ` [PATCH v3 7/8] pull: update docs & code for option compatibility with rebasing Elijah Newren via GitGitGadget
2021-07-22 5:04 ` [PATCH v3 8/8] pull: fix handling of multiple heads Elijah Newren via GitGitGadget
2021-07-22 7:09 ` [PATCH v3 0/8] Handle pull option precedence Felipe Contreras
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=c45cd2396664e915a1d962e6d131505df51b118e.1626930290.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=alexhenrie24@gmail.com \
--cc=avarab@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=matthias.baumgarten@aixigo.com \
--cc=newren@gmail.com \
--cc=sluongng@gmail.com \
--cc=sunshine@sunshineco.com \
/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 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 NNTP newsgroup(s).