Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkout: ignore skip-worktree when virtual #658

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

derrickstolee
Copy link
Collaborator

@derrickstolee derrickstolee commented Jun 19, 2024

As documented in microsoft/VFSForGit#1812, attempting to restore a file fails when using either of these commands in a VFS for Git repo:

  git restore --source=<commit> <path>
  git checkout <commit> -- <path>

To discover the issue, I debugged such a call and found that since opt->ignore_skipworktree is not set, that the restore will not update the index when the file is not hydrated.

I verified that this works as expected, including that the file on-disk is projecting the new index version.


  • This change only applies to the virtualization hook and VFS for Git.

As documented in microsoft/VFSForGit#1812, attempting to restore a file
fails when using either of these commands in a VFS for Git repo:

  git restore --source=<commit> <path>
  git checkout <commit> -- <path>

To discover the issue, I debugged such a call and found that since
opt->ignore_skipworktree is not set, that the restore will not update
the index when the file is not hydrated.

I verified that this works as expected, including that the file on-disk
is projecting the new index version.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
@derrickstolee derrickstolee merged commit b34ae1f into microsoft:vfs-2.45.2 Jun 19, 2024
48 checks passed
dscho added a commit that referenced this pull request Jul 12, 2024
…store` (#674)

This reverts #658 and essentially reopens microsoft/VFSForGit#1812.
Resolves #673.

The issue is that by overriding the `ignore_skip_wortree` value
(normally set by `--ignore-skip-worktree`) we then force Git to hydrate
the entire working directory in a `git restore .`. This leads to some
interesting trade-offs:

1. Users on v2.45.2.vfs.0.2 (where `git restore .` overhydrates), they
can use `git reset --hard` as a better representation of this behavior.
2. Users on any Git version can use `git restore --ignore-skip-worktree
-- <pathspec>` when using a smaller-scale pathspec that corresponds to
files they care about and probably have hydrated.

I will include these workarounds in the VFS for Git issue.

To get to a real solution here, we would somehow need to turn the
`ignore_skip_worktree` bit into two bits:

a. A bit to say "update index entries that have `SKIP_WORKTREE` set".
b. A bit to say "update the working directory even if `SKIP_WORKTREE` is
set".

And perhaps this "working directory" version is what was intended when
adding the `--ignore-skip-worktree` option, but it's more involved and
has upstream implications to make changes here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants