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

Re: Regression in 'git pull --rebase --autostash' since v2.32.0

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jul 17, 2021, 17:03 UTC
Message-ID
<109545c7-7245-6146-d39a-2a44ac450db3@gmail.com>
In-Reply-To
<a0071549-73f6-9636-9279-3f01143a05de@gmail.com>
Le 2021-07-17 à 11:29, Philippe Blain a écrit :
Show 14 quoted lines
> Hi Felipe,
> 
> Your recent clean-up of 'git pull --autostash' seems to unfortunately have made things
> worse if the pull brings new files that conflict with existing untracked files,
> which makes the pull abort,
> and there are tracked files with modifications (so --autostash comes into play).
> 
> Before your change, 'git pull --no-rebase --autostash' did *not* apply the autostash
> after the pull failed, thus loosing modifications to tracked files (and it did not save the
> stash entry !). 'git pull --rebase --autostash' correctly applied the autostash, but ended with
> a strange "error: could not detach HEAD".
> 
> After your change, both 'git pull --no-rebase --autostash' and 'git pull --rebase --autostash'
> have the same buggy behaviour: they do not apply the autostash and do not save it in the stash list.
The change below seem to fix both cases:
diff --git a/builtin/merge.c b/builtin/merge.c
index a8a843b1f5..b2ad70c50a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1560,6 +1560,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
  					  &head_commit->object.oid,
  					  &commit->object.oid,
  					  overwrite_ignore)) {
+			apply_autostash(git_path_merge_autostash(the_repository));
  			ret = 1;
  			goto done;
  		}


*But* from a quick audit of 'cmd_merge', there are still two code paths that
call 'create_autostash' but then fail to apply it before calling 'goto done':

1. the branch 'if (automerge_was_ok)' (line 1693)
2. the branch 'if (!best_strategy)' (line 1704)


Cheers,
Philippe.
Previous: Philippe BlainNext: Felipe Contreras
Message 2 of 7 in “Regression in 'git pull --rebase --autostash' since v2.32.0”
  1. Philippe BlainJul 17, 2021
  2. Philippe BlainJul 17, 2021
  3. Felipe ContrerasJul 17, 2021
  4. Philippe BlainJul 17, 2021
  5. Felipe ContrerasJul 18, 2021
  6. Philippe BlainJul 23, 2021
  7. Felipe ContrerasJul 23, 2021

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.