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

Re: [BUG REPORT] `--autostash` rebase + pre-rebase error ends in corrupt state

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Aug 13, 2024, 10:01 UTC
Message-ID
<61ea41e7-d525-496b-aa2c-f605b99fc3d5@gmail.com>
In-Reply-To
<17ea26263cf57664.70b1dd9aae081c6e.203dcd72f6563036@zivdesk>
Hi Brian
On 09/08/2024 20:29, Brian Lyles wrote:
> If you perform a rebase using `--autostash`, and the pre-rebase hook
> exits with a non-zero exit code, your worktree is left in some sort of
> invalid state. This is reproducible with the following script:

Thanks for reporting this. It looks like the rebase code was written on the assumption that we only write the state files after successfully checking out the commit we're rebasing onto. Unfortunately "--autostash" breaks that assumption as it creates the autostash state file much earlier leading to an inconsistent state if the rebase cannot start. I'll post a fix later this week.

> You're able to recover from this by using `git rebase --quit` and then
> resetting to the commit you were on before attempting the rebase.

I don't think you should need to reset HEAD as it should be untouched. You can get the stashed changes back by running "git stash --apply" with the oid from the "Created autostash: ..." line that rebase prints.

Best Wishes
Phillip
Previous: Brian Lyles
Message 2 of 2 in “[BUG REPORT] `--autostash` rebase + pre-rebase error ends in corrupt state”
  1. Brian LylesAug 9, 2024
  2. Phillip WoodAug 13, 2024

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.