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

Re: [PATCH v4 00/19] pull: default ff-only mode

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Dec 8, 2020, 00:57 UTC
Message-ID
<CAMP44s2hUCd9qc83LReGyjy8N+u++eK6VjwGhDhrX0f0SbKmig@mail.gmail.com>
In-Reply-To
<20201208002648.1370414-1-felipe.contreras@gmail.com>
Hi,

Junio, this is intended for you, I will describe step by step how the warning evolves.

Step 0: This is what we have today:
  Pulling without specifying how to reconcile divergent branches is
  discouraged. You can squelch this message by running one of the following
  commands sometime before your next pull:
    git config pull.rebase false  # merge (the default strategy)
    git config pull.rebase true   # rebase
    git config pull.ff only       # fast-forward only
  You can replace "git config" with "git config --global" to set a default
  preference for all repositories. You can also pass --rebase, --no-rebase,
  or --ff-only on the command line to override the configured default per
  invocation.
> Felipe Contreras (19):
>   doc: pull: explain what is a fast-forward
>   pull: improve default warning

Step 1: This is low-hanging fruit that can be fixed today without any change in behavior:

  Pulling without specifying how to reconcile divergent branches is discouraged;
  you need to specify if you want a merge, or a rebase.
  You can squelch this message by running one of the following commands:
    git config pull.rebase false  # merge (the default strategy)
    git config pull.rebase true   # rebase
    git config pull.ff only       # fast-forward only
  You can replace "git config" with "git config --global" to set a default
  preference for all repositories.
  If unsure, run "git pull --no-rebase".
  Read "git pull --help" for more information.
Show 5 quoted lines
>   pull: refactor fast-forward check
>   pull: cleanup autostash check
>   pull: trivial cleanup
>   pull: move default warning
>   pull: display default warning only when non-ff

At this point we can update the warning to mention that we are inside a non-fast-forward case. But it's not necessary.

>   pull: trivial whitespace style fix
>   pull: introduce --merge option
s/--no-rebase/--merge/
Show 6 quoted lines
>   pull: show warning with --ff
>   rebase: add REBASE_DEFAULT
>   pull: move configurations fetches
>   test: merge-pull-config: trivial cleanup
>   test: pull-options: revert unnecessary changes
>   pull: trivial memory fix

This is the end of part I. At this point the default mode is still "merge", and the only behavior change is that the warning is printed only on the non-fast-forward case.

========================================================================
>   pull: add pull.mode
Step 2: pull.mode={merge,rebase} are specified
  Pulling without specifying how to reconcile divergent branches is discouraged;
  you need to specify if you want a merge, or a rebase.
  You can squelch this message by running one of the following commands:
    git config pull.mode merge    # (the default strategy)
    git config pull.mode rebase
    git config pull.ff only       # fast-forward only
  You can replace "git config" with "git config --global" to set a default
  preference for all repositories.
  If unsure, run "git pull --merge".
  Read "git pull --help" for more information.
>   pull: add pull.mode=ff-only
Step 3: Now pull.mode=ff-only
  Pulling without specifying how to reconcile divergent branches is discouraged;
  you need to specify if you want a merge, or a rebase.
  You can squelch this message by running one of the following commands:
    git config pull.mode merge    # (the default strategy)
    git config pull.mode rebase
    git config pull.mode ff-only  # fast-forward only
  You can replace "git config" with "git config --global" to set a default
  preference for all repositories.
  If unsure, run "git pull --merge".
  Read "git pull --help" for more information.
However, now in addition to the warning, there's an error message:
  The pull was not fast-forward, please either merge or rebase.

This error message is *only* triggered when the user has manually configured "pull.mode=ff-only". And it is an error. The program dies.

And it's not meant to be temporary; it's permanent behavior.
>   pull: advice of future changes

Step 4: Now that pull.mode=ff-only is in place, we can aim for it being the default, and we can tell our users that it will be the default in the future.

  The pull was not fast-forward, in the future you will have to choose
a merge, or a rebase.
  To quell this message you have two main options:
  1. Adopt the new behavior:
    git config --global pull.mode ff-only
  2. Maintain the current behavior:
    git config --global pull.mode merge
  For now we will fall back to the traditional behavior (merge).
  Read "git pull --help" for more information.
This is the end of part II. At this point the default is still "merge".

Unlike part I, in part II we have committed to pull.mode=ff-only to be the new default, and we are already telling users that they can use this new mode to test the new behavior.

We should probably stay a couple of releases at this point, with this warning, and the new behavior already configurable.

Elijah: notice how there's no mention of `git pull --merge`, because
in my opinion now we are telling users this is a temporary *warning*,
and the way to get rid of it properly should be very clear.
========================================================================
>   future: pull: enable ff-only mode by default

The last patch finally enables the ff-only mode by default, and the warning is removed forever.

The only thing that remains now is the fatal error:
  The pull was not fast-forward, please either merge or rebase.

This fatal error is avoided by pull.mode=merge, pull.mode=rebase, pull.rebase=true, pull.rebase=false, pull.rebase=$other, --merge, or --rebase.

It *only* happens when the user does a vanilla "git pull", it's a non-fast-forward update, the user has configured pull.mode=ff-only or has not configured any of the above.

Is it more clear what is my proposal?
Cheers.
-- 
Felipe Contreras
Previous: Felipe Contreras
Message 21 of 21 in “pull: default ff-only mode”
  1. 00/19 pull: default ff-only modeFelipe Contreras, Dec 8, 2020
  2. 01/19 doc: pull: explain what is a fast-forwardFelipe Contreras, Dec 8, 2020
  3. 02/19 pull: improve default warningFelipe Contreras, Dec 8, 2020
  4. 03/19 pull: refactor fast-forward checkFelipe Contreras, Dec 8, 2020
  5. 04/19 pull: cleanup autostash checkFelipe Contreras, Dec 8, 2020
  6. 06/19 pull: move default warningFelipe Contreras, Dec 8, 2020
  7. 05/19 pull: trivial cleanupFelipe Contreras, Dec 8, 2020
  8. 07/19 pull: display default warning only when non-ffFelipe Contreras, Dec 8, 2020
  9. 08/19 pull: trivial whitespace style fixFelipe Contreras, Dec 8, 2020
  10. 09/19 pull: introduce --merge optionFelipe Contreras, Dec 8, 2020
  11. 10/19 pull: show warning with --ffFelipe Contreras, Dec 8, 2020
  12. 11/19 rebase: add REBASE_DEFAULTFelipe Contreras, Dec 8, 2020
  13. 12/19 pull: move configurations fetchesFelipe Contreras, Dec 8, 2020
  14. 14/19 test: pull-options: revert unnecessary changesFelipe Contreras, Dec 8, 2020
  15. 15/19 pull: trivial memory fixFelipe Contreras, Dec 8, 2020
  16. 13/19 test: merge-pull-config: trivial cleanupFelipe Contreras, Dec 8, 2020
  17. 17/19 pull: add pull.mode=ff-onlyFelipe Contreras, Dec 8, 2020
  18. 19/19 future: pull: enable ff-only mode by defaultFelipe Contreras, Dec 8, 2020
  19. 16/19 pull: add pull.modeFelipe Contreras, Dec 8, 2020
  20. 18/19 pull: advice of future changesFelipe Contreras, Dec 8, 2020
  21. Felipe ContrerasDec 8, 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.