-
Notifications
You must be signed in to change notification settings - Fork 452
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
Git Restore Fails with "did not match any file(s) known to git" #1812
Comments
Could you confirm if this is only an issue with
|
Yes, the same error occurs when using |
There was a fix in https://github.com/microsoft/git/releases/tag/v2.45.2.vfs.0.0 that may be helpful to this case. Please check to see if your scenario is fixed when installing that version of Git. |
2.45.2.vfs.0.0 does not help. Also is looks like the issue only happens when the file has not been hydrated yet.
|
I was not able to duplicate the problem on my Mac with 2.45.2.vfs.0.0. I currently don't have a GVFS-enabled machine, so I can't really test the hydration theory. I do wonder if there is some skip-worktree-bit or sparse-index interaction. |
I was able to duplicate the pathspec error using a sparse-checkout when the pathname was in the non-populated (sparse) portion of the worktree. The skip-worktree-bit test in the following sets up the caller to throw the error message when containing loop is finished:
You should extend the sparse-checkout to include the pathname before trying to checkout/restore the content to the version from a specific commit:
Please let us know if this does not address the problem that you are seeing. I only tested a simple non-cone example here and used a pathspec naming a single file. Your sparse-checkout usage may be more complex if you are using cone-mode or other tooling to control the populated region of the worktree, so you may need to adapt the suggestion here accordingly. |
@jeffhostetler: this is a VFS for Git repo, so the user has no control over the sparse-checkout definition or the skip-worktree bits. |
In Office?? I thought they were using Scalar. Anyway, doesn't GVFS set the skip-worktree bit for non-hydrated files? And won't that same piece of code cause the same error? Does the mount daemon clear the skip bit (and delete the CE for it) if it detects a delete on a non-hydrated file? |
When you have it in a state where the pathspec error appears, could you run
Then try the Then try the Thanks! |
Some Azure Pipelines workflows use GVFS clones to do Git operations in an automated scenario. I intend to learn more about what kinds of workflows are doing this so we can see if they can be converted to Scalar clones instead. But that's a much bigger dig than this bug. |
|
Nice! So the mount daemon magically detects the delete of the non-hydrated file and changes the bit flags, then the functioning restore updates the flags again. In both cases, the skip bit is not set (0x4000 0000). So the pathspec matching in the function I printed above is allowed to proceed. So I think that the problem (or at least, what is causing this error) is that the skip-worktree shortcut is too aggressive. I don't know enough about that section of code yet, to say if it wrong or properly guarding the rest of the function (er, that is "works by design" or "the design is wrong"). Thanks. |
So as a workaround, you might consider (but don't tell anyone that I suggested this):
That is, you're going to overwrite the file (whether it exists or not), so clear the skip-worktree bit (which will make Git think that it has been deleted) and then restore it using the SHA from the desired commit. |
|
Ack! I knew that was too easy.... I don't have a GVFS Windows machine, so I can't suggest anything further at this point. Could you use a workaround of "del b ; git restore b" in your scripts for now? |
Yes. I checked in that workaround last week (after I discovered it), but now we are seeing other failures. It looks like if I try to checkout the file (post deletion) on a folder that only contains that file it fails with:
Something like:
|
Humph. I don't have a GVFS Windows machine, so I can't the GVFS mount daemon magic, but (conceptually) it is maintaining the .git/index in-sync with the virtual projection (and magically turning off the skip-worktree bit when the file is hydrated). So, if deleting is too heavy a hammer, just try something like:
Again, the goal is just to force the hydration -- trick the daemon into thinking that you want to write to the file (like your FWIW, a simple read-only descriptor might not be sufficient, because there were plans to let the daemon project read-only Anyway, try running the debug ls-files before and after the |
You might try |
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 <[email protected]>
This should be fixed by microsoft/git#658 when it is merged and released. |
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. ---- * [X] This change only applies to the virtualization hook and VFS for Git.
Hello, all! It turns out the change in microsoft/git#658 was problematic for users who specify a broad pathspec, such as in But this also presents a workaround for this case where only one file (or a small subset of files) is given by the pathspec: use |
…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.
Running git restore for a particular file appears to be not be compatible with GVFS. Repro below:
The text was updated successfully, but these errors were encountered: