My colleague Dan Thompson reported a bug in a sparse checkout, where git stash (after resolving merge conflicts and then making up their mind to stash the changes instead of committing them) would "lose" files (and files that were not even in the sparse checkout's cone!). I first considered changing the behavior of git diff-index to simply ignore skip-worktree entries. But after re-reading the documentation of the skip-worktree bit, I became convinced that this would be incorrect a fix because the command really does what it advertises to do. Then, I briefly considered introducing a flag that would change the behavior thusly, but ended up deciding against it. The actual problem, after all, is the git update-index call and that it heeds the --remove (but not the --add) option for skip-worktree entries. "Heeds", I should say, because the idea of the skip-worktree bit really is documented to imply that the worktree files should be considered identical to their staged versions. So arguably, it could be considered a bug that git update-index --remove even bothers to touch skip-worktree entries. But this behavior has been in place for over 10 years, so I opted to introduce a new mode that does what git stash needs in order to fix the bug. Johannes Schindelin (2): update-index: optionally leave skip-worktree entries alone stash: handle staged changes in skip-worktree files correctly Documentation/git-update-index.txt | 6 ++++++ builtin/stash.c | 5 +++-- builtin/update-index.c | 6 +++++- git-legacy-stash.sh | 3 ++- t/t3903-stash.sh | 11 +++++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) base-commit: 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-355%2Fdscho%2Ffix-stash-with-skip-worktree-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-355/dscho/fix-stash-with-skip-worktree-v1 Pull-Request: https://github.com/gitgitgadget/git/pull/355 -- gitgitgadget