Re: [PATCH] checkout: add --autostash option for branch switching
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 16, 2026, 20:04 UTC
- Message-ID
- <xmqqcy13o81b.fsf@gitster.g>
- In-Reply-To
- <564a8207-6a96-4f42-b0bc-807edafff330@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 5 quoted lines
> Why is the dry-run of unpack_trees() not an extra check? I was assuming > that it was because we do the dry-run and then do it for real after > possibly stashing any local changes. That's why I was wondering if we > could avoid the dry-run by creating the stash if the non-dry-run > unpack_trees() failed.
Ah, I didn't even think about that possibility.
Try to unpack anyway, and if unpack_trees() branch switching succeeds, we are done. Otherwise, we can trust that unpack_trees() did not do _anything_ to the index or the working tree files, so we can create the stash at that time.
Makes sense.
> It turns out I'd misremembered what "git checkout -m > --recurse-submodules" does at the moment - after testing it, it seems to > simply nuke an uncommitted submodule changes rather than merging them.
Makes sense.