All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Konstantin Pereiaslov via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Konstantin Pereiaslov <perk11@perk11.info>
Subject: Re: [PATCH] advice: improve hint for diverging branches.
Date: Tue, 05 Sep 2023 16:20:54 -0700	[thread overview]
Message-ID: <xmqqh6o8p5pl.fsf@gitster.g> (raw)
In-Reply-To: <pull.1570.git.git.1693861162353.gitgitgadget@gmail.com> (Konstantin Pereiaslov via GitGitGadget's message of "Mon, 04 Sep 2023 20:59:22 +0000")

"Konstantin Pereiaslov via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Konstantin Pereiaslov <perk11@perk11.info>
>
> Added a description of what the offered options will do and for pull
> also offered a 3rd option during a pull - a hard reset.
> This option should be helpful for the new users that accidentally
> committed into the wrong branch which is a scenario I saw very
> often.

cf. Documentation/SubmittingPatches:[[describe-changes]]

> The resulting tooltip looks like this for pull:
>
> hint: Diverging branches can't be fast-forwarded.
> Consider the following options:

We do not give "hint:" prefix to this line???

> hint:
> hint: To merge remote changes into your branch:
> hint:   git merge --no-ff
> hint:
> hint: To apply your changes on top of remote changes:
> hint:   git rebase

Hmph, "apply" -> "replay" perhaps?

> hint: To discard your local changes and apply the remote changes:

Here "apply" is definitely a misnomer.  Nothing is applied; you just
discard your work and adopt (or "accept") the state of the remote as
a whole.

> hint:   git reset --hard refs/remotes/upstream/branch-name
> hint:
> hint: Disable this message with "git config advice.diverging false"

OK.

Overall, "... looks like this" should be shown a bit indented so
that the example stands out from the text that explains the example.

> There is some danger because it's semi-destructive, but so are
> other options offered if user doesn't know the commands to
> revert back.

Sorry, but I do not quite understand what you want to say here.

> @@ -1112,8 +1126,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
>  
>  	/* ff-only takes precedence over rebase */
>  	if (opt_ff && !strcmp(opt_ff, "--ff-only")) {
> -		if (divergent)
> -			die_ff_impossible();
> +		if (divergent) {
> +			const char* pull_branch_spec = get_pull_branch(repo, *refspecs);

In this codebase, asterisk sticks to the variable/function
identifier, not types.

But more importantly, what guarantees your recomputation using
'*refspecs' here will match the result of the logic that computed
'divergent', which certainly would have already known what commit we
tried to fast-forward our branch to, and where that commit came
from?  We shouldn't be computing the same thing twice, and in
different ways; that is a sure way to introduce inconsistent
results.

> +			die_ff_impossible_during_pull(pull_branch_spec);
> +		}
>  		opt_rebase = REBASE_FALSE;
>  	}
>  	/* If no action specified and we can't fast forward, then warn. */
>
> base-commit: d814540bb75bbd2257f9a6bf59661a84fe8cf3cf

Thanks.

  reply	other threads:[~2023-09-05 23:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 20:59 [PATCH] advice: improve hint for diverging branches Konstantin Pereiaslov via GitGitGadget
2023-09-05 23:20 ` Junio C Hamano [this message]
2023-09-05 23:55   ` Konstantin Pereiaslov
2023-09-06  0:03   ` Konstantin Pereiaslov

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=xmqqh6o8p5pl.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=perk11@perk11.info \
    /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.