From: Phillip Wood Date: Fri, 29 Aug 2025 13:06:07 GMT Subject: Re: [FEATURE] Proposal: git stash --only-unstaged Message-ID: <9f9e49c5-5612-4e6d-89af-839b353506f1@gmail.com> In-Reply-To: <18A45EC6-2D2C-45A2-8802-0E5060539398@gmail.com> Hi Ben On 19/08/2025 00:41, Ben Knoble wrote: > >> Le 18 août 2025 à 11:14, Phillip Wood a écrit : >> >> On 17/08/2025 17:08, Junio C Hamano wrote: >>> Phillip Wood writes: >>>> To use it create your stash with "git stash push --keep-index" and then >>>> use the script to pop the unstaged changes rather than using "git stash >>>> pop". If the script proves to be useful then perhaps we could add an >>>> "--unstaged" option to "git stash pop" >>> Hmph, would the behaviour useful enough that it should be always >>> enabled, without any new option? I strongly suspect that those who >>> worked on adding "--keep-index" option did not expect the user to be >>> mucking with the working tree files while "testing the staged stuff >>> by updating the working tree files to match it and nothing else", >>> and as long as the end-user stays within that originally designed >>> use case, nothing changes for them, no? > > I can’t particularly comment on the script, but I do think the example > in the docs should either just work or be adjusted to work. I think the example works but may generate conflicts when the stash is popped. One can argue that the conflicts are unnecessary because they could be avoided by popping the unstaged changes but I don't think the example is broken as such. >> Yes it probably would make sense if we knew that the stash had been >> created with "--keep-index". At the moment I don't think there is >> anywhere to tell from looking at the stash if that's the case but we >> could add a trailer to the commit message when we create the stash to >> record that it was created with "--keep-index" and apply only the >> unstaged changes when we see that trailer.> > This seems reasonable; I wonder if there would be any interaction > with the stash import/export features? But perhaps those omitted the > index anyway, I cannot recall. It exports the stash commits as-is so it should be fine I think Thanks Phillip