From 6c886e2a6223aa417a2563fccb11708a5dd83a7c Mon Sep 17 00:00:00 2001 From: Tyrie Vella Date: Mon, 30 Mar 2026 12:08:54 -0700 Subject: [PATCH] worktree remove: use GVFS_SUPPORTS_WORKTREES for skip-clean-check gate The skip-clean-check guard in remove_worktree() was gated on core_virtualfilesystem, which is only initialized by repo_config_get_virtualfilesystem() during index loading. Since the worktree remove path never loads the index before this check, the variable was always NULL, causing check_clean_worktree() to run even when VFSForGit had already unmounted the projection and written the skip-clean-check marker file. This made 'git worktree remove' fail with 'fatal: failed to run git status' in GVFS repos. Replace core_virtualfilesystem with gvfs_config_is_set(GVFS_SUPPORTS_WORKTREES). This is the correct bit to check here: remove_worktree() can only be reached when GVFS_SUPPORTS_WORKTREES is set (cmd_worktree blocks otherwise at line 1501), and it directly expresses that the VFS layer supports worktree operations and knows how to signal when a clean check can be skipped. Unlike core_virtualfilesystem, gvfs_config_is_set() is self-loading from core.gvfs and does not depend on the index having been read. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella --- builtin/worktree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 5d2c458b6b8cf1..1c368c857bbfcf 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -1420,7 +1420,9 @@ static int remove_worktree(int ac, const char **av, const char *prefix, strbuf_release(&errmsg); if (file_exists(wt->path)) { - if (!force && !(core_virtualfilesystem && should_skip_clean_check(wt))) + if (!force && + !(gvfs_config_is_set(the_repository, GVFS_SUPPORTS_WORKTREES) && + should_skip_clean_check(wt))) check_clean_worktree(wt, av[0]); ret |= delete_git_work_tree(wt);