Fix reset --mixed skipping hydrated files due to skip-worktree#2016
Closed
tyrielv wants to merge 2 commits into
Closed
Fix reset --mixed skipping hydrated files due to skip-worktree#2016tyrielv wants to merge 2 commits into
tyrielv wants to merge 2 commits into
Conversation
Adds ReproResetMixedSkipWorktree to CorruptionReproTests. The test hydrates Readme.md via blame (materializes on disk but not in ModifiedPaths, so skip-worktree stays set), then runs reset HEAD~1. On the FunctionalTests/20201014 branch, Readme.md is the only file that differs between HEAD and HEAD~1. The control repo correctly reports it as modified after the reset; the GVFS repo does not because skip-worktree hides the working-tree vs index mismatch. This test is expected to FAIL until the fix is applied. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Adds PrepareForReset pre-command hook (mirroring PrepareForUnstage) that diffs HEAD against the target commit and adds changed files to ModifiedPaths before the reset runs. This ensures skip-worktree is cleared for hydrated files so git correctly reports them as modified. Components: - ResetCommandParser: detects mixed resets, extracts target commit - Program.Reset: sends PrepareForReset IPC to mount process - FileSystemCallbacks.AddResetDiffToModifiedPaths: runs git diff-tree, adds changed paths to ModifiedPaths - InProcessMount: handles PrepareForReset messages - ResetCommandParserTests: 12 unit tests for arg parsing Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
| { | ||
| // Output is null-separated paths. The first entry from diff-tree is | ||
| // the target commit SHA (when given a commit, not a tree), skip it. | ||
| string[] parts = result.Output.Split(new[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); |
There was a problem hiding this comment.
Splitting the diff-tree -z output can leave a stray newline element that gets added to ModifiedPaths.
Contributor
Author
|
More investigation is suggesting this needs to be fixed in git.exe, which makes a wrong assumption that placeholder files don't exist on disk (but they do if they've had contents read) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After
git reset --mixed HEAD~N, hydrated files (read via blame/cat-file but not modified) retain skip-worktree because they are not in ModifiedPaths. Git skips the working-tree vs index comparison for these files, sostatusreports clean when the on-disk content doesn't match the new index entry.Manually confirmed: control repo outputs 224 modified files including
M Readme.md; GVFS repo outputs 223 — Readme.md missing from reset output and status.Fix
Adds a
PrepareForResetpre-command hook (mirroring the existingPrepareForUnstagepattern forestore --staged):git diff-tree HEAD <target>, adds changed paths to ModifiedPathsTesting
ReproResetMixedSkipWorktree): hydrates Readme.md via blame, then resets to HEAD~1 where it changed. Expected to fail without the fix (pushed as first commit to verify CI catches it).ResetCommandParserarg parsingCommits