diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2019-10-30 10:49:38 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-11-02 15:22:45 +0900 |
commit | 4a58c3d7f7a83ebcd4ede635871cab7be24f7f3f (patch) | |
tree | 127863a57bb8f9c640db43557850e6589d6b711c /t | |
parent | update-index: optionally leave skip-worktree entries alone (diff) | |
download | tgif-4a58c3d7f7a83ebcd4ede635871cab7be24f7f3f.tar.xz |
stash: handle staged changes in skip-worktree files correctly
When calling `git stash` while changes were staged for files that are
marked with the `skip-worktree` bit (e.g. files that are excluded in a
sparse checkout), the files are recorded as _deleted_ instead.
The reason is that `git stash` tries to construct the tree reflecting
the worktree essentially by copying the index to a temporary one and
then updating the files from the worktree. Crucially, it calls `git
diff-index` to update also those files that are in the HEAD but have
been unstaged in the index.
However, when the temporary index is updated via `git update-index --add
--remove`, skip-worktree entries mark the files as deleted by mistake.
Let's use the newly-introduced `--ignore-skip-worktree-entries` option
of `git update-index` to prevent exactly this from happening.
Note that the regression test case deliberately avoids replicating the
scenario described above and instead tries to recreate just the symptom.
Reported by Dan Thompson.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t3903-stash.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index b8e337893f..1e977145b8 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1241,4 +1241,15 @@ test_expect_success 'stash --keep-index with file deleted in index does not resu test_path_is_missing to-remove ' +test_expect_success 'stash handles skip-worktree entries nicely' ' + test_commit A && + echo changed >A.t && + git add A.t && + git update-index --skip-worktree A.t && + rm A.t && + git stash && + + git rev-parse --verify refs/stash:A.t +' + test_done |