Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reset when using the sparse-checkout feature.
When using the sparse checkout feature the git reset command will add entries to the index that will have the skip-worktree bit off but will leave the working directory empty. File data is lost because the index version of the files has been changed but there is nothing that is in the working directory. This will cause the next status call to show either deleted for files modified or deleting or nothing for files added. The added files should be shown as untracked and modified files should be shown as modified. To fix this when the reset is running if there is not a file in the working directory and if it will be missing with the new index entry or was not missing in the previous version, we create the previous index version of the file in the working directory so that status will report correctly and the files will be availble for the user to deal with. 2022-03-28: This commit was ejected during the 2.35.0 rebase, and I am cherry-picking it back. We had a user report that "git reset HEAD~1" would fail to update the index properly in a VFS for Git enlistment. No VFS for Git functional test caught this, even though it appears like that exact case should be included. I have locally failed to reproduce the error in a test case, but have verified that the failing case in the full reproduction is fixed by adding this commit again. There is a big change in this version of the code: we condition the check on core_virtualfilesystem instead of core_apply_sparse_checkout, since this is _not_ the right thing to do in the sparse-checkout case, but is the right thing to do for the virtual filesystem case. Signed-off-by: Kevin Willford <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
- Loading branch information