Re: [PATCH] rebase: apply and cleanup autostash when rebase fails to start

2 messages, 2 authors, 2024-08-15 · open the first message on its own page

Re: [PATCH] rebase: apply and cleanup autostash when rebase fails to start

From: Junio C Hamano <hidden>
Date: 2024-08-14 17:27:32

Phillip Wood [off-list ref] writes:
Applying the stash should not fail because the rebase has not started
and so HEAD, the index and the worktree are unchanged since the stash
was created. If it does fail for some reason then apply_autostash()
creates a new entry under refs/stash. We definitely do want to remove
the directory otherwise we're left with the inconsistent state we're
tying to fix.
If it is not expected to fail 99% of times, it feels more prudent to
abort loudly without making further damage to lose information and
ask the user to check what happened in the working tree, rather than
blindly removing the clue to understand what went wrong.  For
example, could the reason why applying the stash failed be because
the user forgot that the working tree was being used for rebasing
and mucked with its contents from say another terminal?

Thanks.

Re: [PATCH] rebase: apply and cleanup autostash when rebase fails to start

From: Phillip Wood <hidden>
Date: 2024-08-15 09:48:03

Hi Junio

On 14/08/2024 18:27, Junio C Hamano wrote:
Phillip Wood [off-list ref] writes:
quoted
Applying the stash should not fail because the rebase has not started
and so HEAD, the index and the worktree are unchanged since the stash
was created. If it does fail for some reason then apply_autostash()
creates a new entry under refs/stash. We definitely do want to remove
the directory otherwise we're left with the inconsistent state we're
tying to fix.
If it is not expected to fail 99% of times, it feels more prudent to
abort loudly without making further damage to lose information and
ask the user to check what happened in the working tree, rather than
blindly removing the clue to understand what went wrong.  For
example, could the reason why applying the stash failed be because
the user forgot that the working tree was being used for rebasing
and mucked with its contents from say another terminal?
If the working tree has changed then the stash will still apply but 
possibly with conflicts - the same thing can happen when the branch has 
been successfully rebased. If there are conflicts then the stash is 
saved in refs/stash as well. This code is just doing what we do at the 
end of a successful rebase so I'm don't really understand what the issue 
is. Looking at finish_rebase() we don't even check the return value of 
apply_autostash() when applying the stash at the end of a successful rebase.

Best Wishes

Phillip
Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help