]> git.ipfire.org Git - thirdparty/git.git/commit
stash: honor stash.index in apply, pop modes
authorD. Ben Knoble <ben.knoble+github@gmail.com>
Mon, 22 Sep 2025 01:39:06 +0000 (21:39 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Sep 2025 03:23:23 +0000 (20:23 -0700)
commit9842c0c7492d2858d64ef81128f7b1f0b38e326b
treefee23eea8f05af177597ca9af2899faf3f3c6b20
parent88b5b8d886b54f5020040a3b3a534f7c102a6293
stash: honor stash.index in apply, pop modes

With stash.index=true, git-stash(1) command now tries to reinstate the
index by default in the "apply" and "pop" modes. Not doing so creates a
common trap [1], [2]: "git stash apply" is not the reverse of "git stash
push" because carefully staged indices are lost and have to be manually
recreated. OTOH, this mode is not always desirable and may create more
conflicts when applying stashes. As usual, "--no-index" will disable
this behavior if you set "stash.index".

[1]: https://lore.kernel.org/git/CAPx1GvcxyDDQmCssMjEnt6JoV6qPc5ZUpgPLX3mpUC_4PNYA1w@mail.gmail.com/
[2]: https://lore.kernel.org/git/c5a811ac-8cd3-c389-ac6d-29020a648c87@gmail.com/

Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/stash.adoc
builtin/stash.c
t/t3903-stash.sh