Re: [PATCH v2 12/14] pull: show warning with --ff
- From
Elijah Newren <newren@gmail.com>
- Date
- Dec 4, 2020, 23:41 UTC
- Message-ID
- <CABPp-BE5zvCAmfHE_1_D3boMg5rMcU0iyJJp+yiLwSu2DsySLg@mail.gmail.com>
- In-Reply-To
- <20201204061623.1170745-13-felipe.contreras@gmail.com>
On Thu, Dec 3, 2020 at 10:16 PM Felipe Contreras <felipe.contreras@gmail.com> wrote:
Show 54 quoted lines
>
> It's unclear why --ff should remove the warning, since:
>
> git pull --ff
>
> Is implicitly the same as:
>
> git pull
>
> Unless of course pull.ff is specified otherwise.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
> builtin/pull.c | 2 +-
> t/t7601-merge-pull-config.sh | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/pull.c b/builtin/pull.c
> index ebf2ac687b..e389ffcdc3 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -1020,7 +1020,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
> die(_("The pull was not fast-forward, please either merge or rebase.\n"
> "If unsure, run \"git pull --merge\"."));
> }
> - if (opt_verbosity >= 0 && !opt_ff) {
> + if (opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) {
> advise(_("Pulling without specifying how to reconcile divergent branches is\n"
> "discouraged; you need to specify if you want a merge, or a rebase.\n"
> "You can squelch this message by running one of the following commands:\n"
> diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
> index 1de64e6cc5..d709799f8b 100755
> --- a/t/t7601-merge-pull-config.sh
> +++ b/t/t7601-merge-pull-config.sh
> @@ -46,7 +46,7 @@ test_expect_success 'pull.rebase not set and pull.ff=true' '
> git reset --hard c2 &&
> test_config pull.ff true &&
> git pull . c1 2>err &&
> - test_i18ngrep ! "Pulling without specifying how to reconcile" err
> + test_i18ngrep "Pulling without specifying how to reconcile" err
> '
>
> test_expect_success 'pull.rebase not set and pull.ff=false' '
> @@ -78,7 +78,7 @@ test_expect_success 'pull.rebase not set and --merge given' '
> test_expect_success 'pull.rebase not set and --ff given' '
> git reset --hard c2 &&
> git pull --ff . c1 2>err &&
> - test_i18ngrep ! "Pulling without specifying how to reconcile" err
> + test_i18ngrep "Pulling without specifying how to reconcile" err
> '
>
> test_expect_success 'pull.rebase not set and --no-ff given' '
> --
> 2.29.2Ah, this answers one of my earlier questions. I'd be tempted to move this earlier in the series; it seems like an obvious cleanup and helps explain the "opt_ff" flag that keeps coming up for readers of the series.