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
Jeff King <peff@peff.net>
Date
Nov 24, 2020, 07:19 UTC
Message-ID
<X7y0GbBQa0a5Alh0@coredump.intra.peff.net>
In-Reply-To
<CAMP44s08mEyYqbjOeTeS46CngrbQMqP2=cMr1dtRLLk_BLAq3w@mail.gmail.com>
On Mon, Nov 23, 2020 at 09:41:05PM -0600, Felipe Contreras wrote:
Show 11 quoted lines
> 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. ;)

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.

Show 7 quoted lines
> 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.
That said...
Show 6 quoted lines
> 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).

-Peff
Previous: Felipe ContrerasNext: Felipe Contreras
Message 18 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.