git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Theodore Y. Ts'o" <tytso@mit.edu>,
	"Alex Henrie" <alexhenrie24@gmail.com>,
	"Vít Ondruch" <vondruch@redhat.com>,
	"Git mailing list" <git@vger.kernel.org>
Subject: Re: Pick the right default and stop warn on `git pull`
Date: Tue, 24 Nov 2020 01:48:56 -0600	[thread overview]
Message-ID: <CAMP44s31OqnRnMO3bcO43VyUCP27o8UGPA5ognGi1s8Se+CRiw@mail.gmail.com> (raw)
In-Reply-To: <X7y0GbBQa0a5Alh0@coredump.intra.peff.net>

On Tue, Nov 24, 2020 at 1:19 AM Jeff King <peff@peff.net> wrote:
>
> On Mon, Nov 23, 2020 at 09:41:05PM -0600, Felipe Contreras wrote:
>
> > What we really need is something like:
> >
> > 1. git pull # fail by default unless it's a fast-forward
> > 2. git pull --merge # force a merge (unless it's a fast-forward,
> > depending on pull.ff)
> > 3. git pull --rebase # force a rebase (unless it's a fast-forward,
> > depending on pull.ff)
> >
> > Therefore, what we really want is "git pull --rebase" *ignore*
> > "pull.ff=only" (a possible default) or ignore "pull.rebase=ff-only"
> > (also another possible default).
>
> Yep. After reading the first half of your mail, I started to respond
> with the exact same thing. The key thing is letting the command-line
> options override all of the related config. But I guess after reading to
> the end that you don't actually like this. ;)

Yes, the command-line options should override the configuration, and
the configuration should override the default.

I'm not sure what makes you think I wouldn't like that.

> I do agree it would be more clear in the long run with a single option
> (config and command-line) that makes it clear the values are mutually
> exclusive. I'm just not sure if it's painful to get there without
> breaking compatibility or introducing confusion in the meantime.

I think it is possible. I did the patches several years ago. And I'm
working on the patches right now. We'll see.

> > It would be possible to do something like:
> >
> >   if (!opt_rebase && (!opt_ff || !strcmp(opt_ff, "--ff-only")))
> >     turn_default_behavior = 1;
> >
> > But then how would we distinguish between "git pull", and "git pull
> > --no-rebase" (aka. "git pull --merge" / "pull.rebase=false")?
>
> I'm not sure what you mean. We can tell the difference between those
> based on what we saw on the command-line option. I.e., your
> "!opt_rebase" is really a tri-state, which allows something like:
>
>   if (opt_rebase == REBASE_UNSET) {
>           if (opt_ff == FF_UNSET)
>                   opt_ff = ff_default; /* from config or baked-in */
>           }
>           opt_rebase = rebase_default;
>   }
>
> but I didn't look at the logic in git-pull.

Well, in git-pull there's a callback called: parse_opt_rebase(), and
if no argument is passed, then it returns REBASE_FALSE (0).

The rest of the code assumes 0 is no-rebase (i.e. merge).

There's no REBASE_UNSET.

Granted, it may be possible to change all the code, introduce a
REBASE_UNSET, and make it so 0 is not REBASE_FALSE, and so on.
Additionally, the code that deals with the configuration part needs to
be changed too.

I'd rather not.

> > This is just too much unnecessary complication There's no need to
> > entertain a dozen possible heuristics to avoid "pull.mode", none of
> > which avoid breaking existing behavior.
> >
> > Let's just accept we need push.mode, and then we can have everything:
> > default, ff-only, merge, rebase.
>
> I think it could be possible for the documentation to make clear the
> interactions, especially if the feature is designed with eventual
> deprecation of other options (e.g., if it says "pull.mode=ff-only" means
> that pull.ff won't be examined, and there's no need to ever use it
> anymore).

I'm not sure there will be no need for "pull.ff". Even with
"pull.mode=ff-only", you should be able to do "git pull --merge"
(should override the configured mode), in which case pull.ff will be
considered (and maybe in "git pull --rebase" too).

Regarding the documentation; I think it should be possible to describe
the interactions clearly, but as a sequence of overrides, and when no
override is specified (default) do something sensible (which right now
it's quite complex to determine).

Cheers.

-- 
Felipe Contreras

  reply	other threads:[~2020-11-24  7:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 15:13 Pick the right default and stop warn on `git pull` Vít Ondruch
2020-11-23 17:59 ` Alex Henrie
2020-11-23 19:13   ` Theodore Y. Ts'o
2020-11-23 19:40     ` Felipe Contreras
2020-11-23 20:20       ` Theodore Y. Ts'o
2020-11-23 20:34         ` Felipe Contreras
2020-11-23 21:48           ` Jeff King
2020-11-23 22:03             ` Alex Henrie
2020-11-24  0:37               ` Jeff King
2020-11-23 22:39             ` Junio C Hamano
2020-11-23 22:55             ` Felipe Contreras
2020-11-24  0:39               ` Jeff King
2020-11-24  0:57                 ` Felipe Contreras
2020-11-24  1:23                   ` Jeff King
2020-11-24  2:18                     ` Junio C Hamano
2020-11-24  2:32                       ` Jeff King
2020-11-24  3:41                         ` Felipe Contreras
2020-11-24  7:19                           ` Jeff King
2020-11-24  7:48                             ` Felipe Contreras [this message]
2020-11-24  8:07                               ` Jeff King
2020-11-24 10:35                           ` Vít Ondruch
2020-11-24 20:21                           ` Alex Henrie
2020-11-24 22:11                             ` Felipe Contreras
2020-11-24 23:23                               ` Alex Henrie
2020-11-25  0:39                                 ` Junio C Hamano
2020-11-26  1:02                                   ` Felipe Contreras
2020-11-23 19:12 ` Junio C Hamano
2020-11-23 19:37   ` Felipe Contreras
2020-11-23 19:43 ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAMP44s31OqnRnMO3bcO43VyUCP27o8UGPA5ognGi1s8Se+CRiw@mail.gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=tytso@mit.edu \
    --cc=vondruch@redhat.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).