All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Erwin Villejo via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Erwin Villejo <erwinvillejo@gmail.com>,
	Erwin Villejo <erwin.villejo@gmail.com>
Subject: Re: [PATCH] pull: should be noop when already-up-to-date
Date: Thu, 18 Nov 2021 15:50:58 -0800	[thread overview]
Message-ID: <xmqqbl2huiot.fsf@gitster.g> (raw)
In-Reply-To: pull.1078.git.1637135750674.gitgitgadget@gmail.com

"Erwin Villejo via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Erwin Villejo <erwin.villejo@gmail.com>
>
> The already-up-to-date pull bug was fixed for --ff-only but it did not
> include the case where --ff or --ff-only are not specified. This updates
> the --ff-only fix to include the case where --ff or --ff-only are not
> specified in command line flags or config.
>
> Signed-off-by: Erwin Villejo <erwin.villejo@gmail.com>
> ---

> @@ -1102,15 +1103,16 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	can_ff = get_can_ff(&orig_head, &merge_heads);
> +	divergent = !can_ff && !already_up_to_date(&orig_head, &merge_heads);
>  
>  	/* ff-only takes precedence over rebase */
>  	if (opt_ff && !strcmp(opt_ff, "--ff-only")) {
> -		if (!can_ff && !already_up_to_date(&orig_head, &merge_heads))
> +		if (divergent)
>  			die_ff_impossible();
>  		opt_rebase = REBASE_FALSE;
>  	}
>  	/* If no action specified and we can't fast forward, then warn. */
> -	if (!opt_ff && rebase_unspecified && !can_ff) {
> +	if (!opt_ff && rebase_unspecified && divergent) {
>  		show_advice_pull_non_ff();
>  		die(_("Need to specify how to reconcile divergent branches."));
>  	}

Looks correct.  I wonder if there is a simplify these two checks,
but let's keep the original code structure for now in this step,
which is about correctness.

Will apply.  Thanks.

> diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
> index 6275641b9c2..bd238d89b0c 100755
> --- a/t/t7601-merge-pull-config.sh
> +++ b/t/t7601-merge-pull-config.sh
> @@ -387,6 +387,12 @@ test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
>  	test_must_fail git pull . c3
>  '
>  
> +test_expect_success 'already-up-to-date pull succeeds with unspecified pull.ff' '
> +	git reset --hard c1 &&
> +	git pull . c0 &&
> +	test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
> +'
> +
>  test_expect_success 'already-up-to-date pull succeeds with "only" in pull.ff' '
>  	git reset --hard c1 &&
>  	test_config pull.ff only &&
>
> base-commit: cd3e606211bb1cf8bc57f7d76bab98cc17a150bc

      reply	other threads:[~2021-11-18 23:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17  7:55 [PATCH] pull: should be noop when already-up-to-date Erwin Villejo via GitGitGadget
2021-11-18 23:50 ` Junio C Hamano [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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqbl2huiot.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=erwin.villejo@gmail.com \
    --cc=erwinvillejo@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.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 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.