pull: abort if --ff-only is given and fast-forwarding is impossible

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alex Henrie
2021-07-21 01:42:19 +00:00
committed by Junio C Hamano
parent 1d25e5bdf5
commit 3d5fc24dae
5 changed files with 20 additions and 9 deletions

View File

@ -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) {