From 40fff5e35008676ec8d34cea143675ecca4c09e7 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Wed, 19 Jun 2024 10:56:37 -0400 Subject: [PATCH] checkout: ignore skip-worktree when virtual 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= git checkout -- 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 --- builtin/checkout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/checkout.c b/builtin/checkout.c index dca1fe9f1054f2..b1702d75f8aa3b 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1,5 +1,6 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "gvfs.h" #include "advice.h" #include "branch.h" #include "cache-tree.h" @@ -1758,6 +1759,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix, } opts->track = BRANCH_TRACK_UNSPECIFIED; + opts->ignore_skipworktree = gvfs_config_is_set(GVFS_USE_VIRTUAL_FILESYSTEM); if (!opts->accept_pathspec && !opts->accept_ref) BUG("make up your mind, you need to take _something_");