Re: [PATCH] builtin/stash: configs keepIndex, includeUntracked
- From
- Ricardo C <rpc01234@gmail.com>
- Date
- Feb 21, 2024, 23:14 UTC
- Message-ID
- <ec72c1f0-bcac-4982-bb67-cdbc8c47eafe@gmail.com>
- In-Reply-To
- <xmqq4je1o9yu.fsf@gitster.g>
On 2/21/24 15:09, Junio C Hamano wrote:
Show 16 quoted lines
> Ricardo C <rpc01234@gmail.com> writes: > >> Permanently enabling keepIndex is mainly intended for people that like >> to stash their unstaged changes before committing (e.g., for testing >> them independently of other changes). The main issue with what you >> recommend is that, if they forget to use `-k`, then the entire state >> of the index is lost, which is especially problematic if the changes >> were interactively staged. > > Doesn't "git stash pop --index" meant to recover from such a > mistake, though? If you stash, because your "git commit" notices > there is no change after you did "git stash" without "-k", your > recovery to "pop --index" would apply the changes to the index and > to the working tree on top of exactly the same commit, so there is > no risk of losing any changes by doing so, right? IOW, such a pop > will always round-trip.
Oh, wow, I didn't realize that was a thing (I mistakenly interpreted the documentation to mean that it added the entire stash to the index). This does help a lot, thanks! I guess keepIndex is a lot less important, so this should mainly be about includeUntracked... but now I'm also longing for a config to have --index on pop/apply by default :P
Interestingly, it seems like frontend support for --index is very variable. VScode is probably the most popular frontend and doesn't seem to have any support for it, while more niche frontends like Emacs Magit and vim-fugitive do support it and moreover have it as the default. Maybe the real issue here is lack of awareness of that flag, and the solution is just to spread the word about it.
Thanks again,
Ricardo