git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Pick the right default and stop warn on `git pull`

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Nov 24, 2020, 03:41 UTC
Message-ID
<CAMP44s08mEyYqbjOeTeS46CngrbQMqP2=cMr1dtRLLk_BLAq3w@mail.gmail.com>
In-Reply-To
<X7xw0xb9UnGKbS8m@coredump.intra.peff.net>
On Mon, Nov 23, 2020 at 8:32 PM Jeff King <peff@peff.net> wrote:
> On Mon, Nov 23, 2020 at 06:18:40PM -0800, Junio C Hamano wrote:
Show 23 quoted lines
> > So an obvious thing we could do, if pull.mode is too much of a
> > change, is to make "pull --rebase" codepath honor pull.ff as well,
> > perhaps?  I.e. those who set pull.ff=only are saying that "please
> > stop me when I have any local change---I want to be notified if my
> > pull on this branch results in anything but a fast-forward from the
> > upstream".
> >
> > And then making an unconfigured pull.ff to default to pull.ff=only
> > may give a proper failure whether you merge or rebase.  I dunno.
>
> Yeah, I would be perfectly happy with that (and it's in fact what I
> _thought_ was happening before today's discussion).
>
> I do wonder if anybody has set:
>
>   pull.rebase=true
>   pull.ff=only
>
> which would then refuse to rebase at all, and whether they would be
> annoyed. I am scratching my head over why one would do that, though. It
> is meaningful only if you usually rebase, but when you say "--no-rebase"
> you want to make sure you do not create a merge commit. Which seems
> weird.
I think you are losing track of the goal.
The goal is that *eventually*:
1. No warning is issued
2. No configuration is needed
3. The default behavior is sane.

The whole point of "pull.rebase=ff-only" (aka. "pull.mode=ff-only") was to make it the *default*.

If you make "pull.ff=only" the default, *and* you make "git pull --rebase" respect that, then "git pull --rebase" will fail by default (unless it's a fast-forward).

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).

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")?

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.

Cheers.
-- 
Felipe Contreras
Previous: Jeff KingNext: Jeff King
Message 17 of 29 in “Pick the right default and stop warn on `git pull`”
  1. Vít OndruchNov 23, 2020
  2. Alex HenrieNov 23, 2020
  3. Theodore Y. Ts'oNov 23, 2020
  4. Felipe ContrerasNov 23, 2020
  5. Theodore Y. Ts'oNov 23, 2020
  6. Felipe ContrerasNov 23, 2020
  7. Jeff KingNov 23, 2020
  8. Alex HenrieNov 23, 2020
  9. Jeff KingNov 24, 2020
  10. Junio C HamanoNov 23, 2020
  11. Felipe ContrerasNov 23, 2020
  12. Jeff KingNov 24, 2020
  13. Felipe ContrerasNov 24, 2020
  14. Jeff KingNov 24, 2020
  15. Junio C HamanoNov 24, 2020
  16. Jeff KingNov 24, 2020
  17. Felipe ContrerasNov 24, 2020
  18. Jeff KingNov 24, 2020
  19. Felipe ContrerasNov 24, 2020
  20. Jeff KingNov 24, 2020
  21. Vít OndruchNov 24, 2020
  22. Alex HenrieNov 24, 2020
  23. Felipe ContrerasNov 24, 2020
  24. Alex HenrieNov 24, 2020
  25. Junio C HamanoNov 25, 2020
  26. Felipe ContrerasNov 26, 2020
  27. Junio C HamanoNov 23, 2020
  28. Felipe ContrerasNov 23, 2020
  29. Felipe ContrerasNov 23, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.