stash: fix handling removed files with --keep-index
authorThomas Gummerer <t.gummerer@gmail.com>
Tue, 16 Jul 2019 14:23:22 +0000 (15:23 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Jul 2019 19:58:20 +0000 (12:58 -0700)
commitb932f6a5e8cdbb33eff4563fdfb1eae9ebf70a65
tree5720cb6a46369f6b97e3a64960243ccadb2a19bf
parentb697d92f56511e804b8ba20ccbe7bdc85dc66810
stash: fix handling removed files with --keep-index

git stash push --keep-index is supposed to keep all changes that have
been added to the index, both in the index and on disk.

Currently this doesn't behave correctly when a file is removed from
the index.  Instead of keeping it deleted on disk, --keep-index
currently restores the file.

Fix that behaviour by using 'git checkout' in no-overlay mode which
can faithfully restore the index and working tree.  This also
simplifies the code.

Note that this will overwrite untracked files if the untracked file
has the same name as a file that has been deleted in the index.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/stash.c
t/t3903-stash.sh