]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fsmonitor-settings: VFS for Git virtual repos are incompatible
authorJeff Hostetler <jeffhost@microsoft.com>
Thu, 26 May 2022 21:47:00 +0000 (21:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 22:59:26 +0000 (15:59 -0700)
VFS for Git virtual repositories are incompatible with FSMonitor.

VFS for Git is a downstream fork of Git.  It contains its own custom
file system watcher that is aware of the virtualization.  If a working
directory is being managed by VFS for Git, we should not try to watch
it because we may get incomplete results.

We do not know anything about how VFS for Git works, but we do
know that VFS for Git working directories contain a well-defined
config setting.  If it is set, mark the working directory as
incompatible.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/fsmonitor/fsm-settings-win32.c
fsmonitor-settings.c
fsmonitor-settings.h
t/t7519-status-fsmonitor.sh

index 7fce32a3c5ba0e3877329c3dcf85141a690d566b..ee78bba38e322d6c57ebf3df3396f11b77e59680 100644 (file)
@@ -3,7 +3,33 @@
 #include "repository.h"
 #include "fsmonitor-settings.h"
 
+/*
+ * VFS for Git is incompatible with FSMonitor.
+ *
+ * Granted, core Git does not know anything about VFS for Git and we
+ * shouldn't make assumptions about a downstream feature, but users
+ * can install both versions.  And this can lead to incorrect results
+ * from core Git commands.  So, without bringing in any of the VFS for
+ * Git code, do a simple config test for a published config setting.
+ * (We do not look at the various *_TEST_* environment variables.)
+ */
+static enum fsmonitor_reason check_vfs4git(struct repository *r)
+{
+       const char *const_str;
+
+       if (!repo_config_get_value(r, "core.virtualfilesystem", &const_str))
+               return FSMONITOR_REASON_VFS4GIT;
+
+       return FSMONITOR_REASON_OK;
+}
+
 enum fsmonitor_reason fsm_os__incompatible(struct repository *r)
 {
+       enum fsmonitor_reason reason;
+
+       reason = check_vfs4git(r);
+       if (reason != FSMONITOR_REASON_OK)
+               return reason;
+
        return FSMONITOR_REASON_OK;
 }
index f67db913f5753d8284edb250ec4ea61357c90e85..600ae165ab1f51baa362f98e2c350a8c5360e0d5 100644 (file)
@@ -207,6 +207,12 @@ char *fsm_settings__get_incompatible_msg(const struct repository *r,
                            _("bare repository '%s' is incompatible with fsmonitor"),
                            xgetcwd());
                goto done;
+
+       case FSMONITOR_REASON_VFS4GIT:
+               strbuf_addf(&msg,
+                           _("virtual repository '%s' is incompatible with fsmonitor"),
+                           r->worktree);
+               goto done;
        }
 
        BUG("Unhandled case in fsm_settings__get_incompatible_msg: '%d'",
index 6cb0d8e7d9fa6de2309e9813233babc8863eb39b..a48802cde9c7a86c9a8504a5929e156d116779b8 100644 (file)
@@ -17,6 +17,7 @@ enum fsmonitor_reason {
        FSMONITOR_REASON_UNTESTED = 0,
        FSMONITOR_REASON_OK, /* no incompatibility or when disabled */
        FSMONITOR_REASON_BARE,
+       FSMONITOR_REASON_VFS4GIT, /* VFS for Git virtualization */
 };
 
 void fsm_settings__set_ipc(struct repository *r);
index 9a8e21c56084508c8cfb9d033adfbf7e85f3777e..156895f943747017dd249954913bc8baf6c7d803 100755 (executable)
@@ -78,6 +78,15 @@ test_expect_success FSMONITOR_DAEMON 'run fsmonitor-daemon in bare repo' '
        grep "bare repository .* is incompatible with fsmonitor" actual
 '
 
+test_expect_success MINGW,FSMONITOR_DAEMON 'run fsmonitor-daemon in virtual repo' '
+       test_when_finished "rm -rf ./fake-virtual-clone actual" &&
+       git init fake-virtual-clone &&
+       test_must_fail git -C ./fake-virtual-clone \
+                          -c core.virtualfilesystem=true \
+                          fsmonitor--daemon run 2>actual &&
+       grep "virtual repository .* is incompatible with fsmonitor" actual
+'
+
 test_expect_success 'setup' '
        mkdir -p .git/hooks &&
        : >tracked &&