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

Re: [PATCH] pull: add pull.autoStash config option

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 17, 2025, 03:27 UTC
Message-ID
<CAPig+cTQ017qGK_Qx04+R_0rCXEOirW+oLEjeaDoCFJiQbnsGw@mail.gmail.com>
In-Reply-To
<20250717030732.75106-1-yldhome2d2@gmail.com>
On Wed, Jul 16, 2025 at 11:07 PM Lidong Yan <yldhome2d2@gmail.com> wrote:
Show 5 quoted lines
> Git uses the `rebase.autoStash` option to decide if git-pull is allowed
> when the working tree has uncommitted changes. However, since the
> documentation does not explicitly state this, users may find it difficult
> to associate `rebase.autoStash` with the git-pull command. Add
> `pull.autoStash` option along with its documentation.
I have no opinion as to whether this is a good path forward.
> `pull.autoStash` provides the same functionality as `rebase.autoStash`
> but is more user-friendly because its prefix clearly associates it
> with git-pull commands.

Rather than "user-friendly", perhaps a better way to phrase it would be to say that `pull.autoStash` is more *discoverable*.

> Additionally, when both options are set,
> `pull.autoStash` takes precedence and overrides the value of
> `rebase.autoStash`.

This was a question which immediately popped into my head, so it's nice to see that you considered it and discussed it in the commit message.

Show 5 quoted lines
> Signed-off-by: Lidong Yan <yldhome2d2@gmail.com>
> ---
>  Documentation/config/pull.adoc |  9 +++++++++
>  builtin/pull.c                 | 10 +++++++---
>  2 files changed, 16 insertions(+), 3 deletions(-)

You will want to add one or more new tests to a test script to verify that this new configuration works as expected, and probably also to verify that `pull.autoStash` takes precedence over `rebase.autoStash`.

Show 6 quoted lines
> diff --git a/Documentation/config/pull.adoc b/Documentation/config/pull.adoc
> @@ -13,6 +13,15 @@ pull.rebase::
> +pull.autoStash::
> +       When true, Git will automatically perform a `git stash` before the
> +       operation and then restore the local changes with `git stash pop`
> +       after the merge or rebase is complete. This means that you can run
I wonder if you meant "pull" instead of "merge or rebase".
> +       pull on a dirty worktree. Noticed that `rebase.autoStash` provides
s/Noticed/Notice/
> +       the same functionality, but `pull.autoStash` overrides its behavior
Rather: "...same functionality as `pull.autoStash` but overrides the
latter when..."
Show 8 quoted lines
> +       when both are set. This option can be overridden by the `--no-autostash`
> +       and `--autostash` options of linkgit:git-pull[1]. Defaults to false.
> diff --git a/builtin/pull.c b/builtin/pull.c
> @@ -1052,7 +1056,7 @@ int cmd_pull(int argc,
>         if (opt_rebase) {
>                 if (opt_autostash == -1)
> -                       opt_autostash = config_autostash;
> +                       opt_autostash = config_pull_autostash == -1 ? config_rebase_autostash : config_pull_autostash;
You may want to wrap this over-long line. Perhaps:
    opt_autostash = config_pull_autostash == -1 ?
        config_rebase_autostash : config_pull_autostash;
Previous: Lidong YanNext: Lidong Yan
Message 12 of 23 in “[BUG] git pull ignores pull.autostash=true configuration when used with --git-dir and --work-tree flags on a bare repository”
  1. Bryan LeeJul 15, 2025
  2. Lidong YanJul 15, 2025
  3. Bryan LeeJul 15, 2025
  4. Bryan LeeJul 15, 2025
  5. Lidong YanJul 15, 2025
  6. Junio C HamanoJul 15, 2025
  7. Lidong YanJul 16, 2025
  8. Johannes SixtJul 16, 2025
  9. Lidong YanJul 16, 2025
  10. Junio C HamanoJul 16, 2025
  11. pull: add pull.autoStash config optionLidong Yan, Jul 17, 2025
  12. Eric SunshineJul 17, 2025
  13. Lidong YanJul 17, 2025
  14. Junio C HamanoJul 17, 2025
  15. Lidong YanJul 17, 2025
  16. Junio C HamanoJul 17, 2025
  17. Junio C HamanoJul 17, 2025
  18. pull: add pull.autoStash config optionLidong Yan, Jul 18, 2025
  19. Junio C HamanoJul 18, 2025
  20. Lidong YanJul 19, 2025
  21. pull: add pull.autoStash config optionLidong Yan, Jul 20, 2025
  22. Junio C HamanoJul 21, 2025
  23. Ben KnobleJul 17, 2025

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.