From dbced3ec51c9a265208728b329ed50d96c849ae1 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Thu, 6 Mar 2025 11:12:35 +0000 Subject: [PATCH 1/6] git.c: add VFS enabled cmd blocking Add the ability to block built-in commands based on if the `core.gvfs` setting has the `GVFS_USE_VIRTUAL_FILESYSTEM` bit set. This allows us to selectively block commands that use the GVFS protocol, but don't use VFS for Git (for example repos cloned via `scalar clone` against Azure DevOps). Signed-off-by: Matthew John Cheetham --- git.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git.c b/git.c index dc740e74dbc107..6e567420a1aba5 100644 --- a/git.c +++ b/git.c @@ -32,6 +32,7 @@ #define DELAY_PAGER_CONFIG (1<<4) #define NO_PARSEOPT (1<<5) /* parse-options is not used */ #define BLOCK_ON_GVFS_REPO (1<<6) /* command not allowed in GVFS repos */ +#define BLOCK_ON_VFS_ENABLED (1<<7) /* command not allowed when virtual file system is used */ struct cmd_struct { const char *cmd; @@ -542,6 +543,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct if (!help && p->option & BLOCK_ON_GVFS_REPO && gvfs_config_is_set(GVFS_BLOCK_COMMANDS)) die("'git %s' is not supported on a GVFS repo", p->cmd); + if (!help && p->option & BLOCK_ON_VFS_ENABLED && gvfs_config_is_set(GVFS_USE_VIRTUAL_FILESYSTEM)) + die("'git %s' is not supported when using the virtual file system", p->cmd); + if (run_pre_command_hook(the_repository, argv)) die("pre-command hook aborted command"); From 294fd9b7d980d0d17e6f0fe12d57185797b1d903 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Thu, 6 Mar 2025 11:14:37 +0000 Subject: [PATCH 2/6] git.c: permit repack cmd in Scalar repos Loosen the blocking of the `repack` command from all "GVFS repos" (those that have `core.gvfs` set) to only those that actually use the virtual file system (VFS for Git only). This allows for `repack` to be used in Scalar clones. Signed-off-by: Matthew John Cheetham --- git.c | 2 +- t/t0402-block-command-on-gvfs.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/git.c b/git.c index 6e567420a1aba5..65ebfd97ed4972 100644 --- a/git.c +++ b/git.c @@ -685,7 +685,7 @@ static struct cmd_struct commands[] = { { "remote", cmd_remote, RUN_SETUP }, { "remote-ext", cmd_remote_ext, NO_PARSEOPT }, { "remote-fd", cmd_remote_fd, NO_PARSEOPT }, - { "repack", cmd_repack, RUN_SETUP | BLOCK_ON_GVFS_REPO }, + { "repack", cmd_repack, RUN_SETUP | BLOCK_ON_VFS_ENABLED }, { "replace", cmd_replace, RUN_SETUP }, { "replay", cmd_replay, RUN_SETUP }, { "rerere", cmd_rerere, RUN_SETUP }, diff --git a/t/t0402-block-command-on-gvfs.sh b/t/t0402-block-command-on-gvfs.sh index 3ec7620ce6194d..a8f7fb07a603e2 100755 --- a/t/t0402-block-command-on-gvfs.sh +++ b/t/t0402-block-command-on-gvfs.sh @@ -22,7 +22,6 @@ not_with_gvfs fsck not_with_gvfs gc not_with_gvfs gc --auto not_with_gvfs prune -not_with_gvfs repack not_with_gvfs submodule status not_with_gvfs update-index --index-version 2 not_with_gvfs update-index --skip-worktree @@ -36,4 +35,14 @@ test_expect_success 'test gc --auto succeeds when disabled via config' ' git gc --auto ' +test_expect_success 'test repack fails with VFS bit enabled' ' + test_config core.gvfs true && + test_must_fail git repack +' + +test_expect_success 'test repack succeeds with VFS bit disabled' ' + test_config core.gvfs 150 && + git repack +' + test_done From 66f6c4c87abc789063605334dd54afe5e243e3a7 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Thu, 13 Mar 2025 13:31:14 +0000 Subject: [PATCH 3/6] git.c: permit fsck cmd in Scalar repos Loosen the blocking of the `fsck` command from all "GVFS repos" (those that have `core.gvfs` set) to only those that actually use the virtual file system (VFS for Git only). This allows for `fsck` to be used in Scalar clones. Signed-off-by: Matthew John Cheetham --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.c b/git.c index 65ebfd97ed4972..059a724ca50c9c 100644 --- a/git.c +++ b/git.c @@ -629,7 +629,7 @@ static struct cmd_struct commands[] = { { "for-each-ref", cmd_for_each_ref, RUN_SETUP }, { "for-each-repo", cmd_for_each_repo, RUN_SETUP_GENTLY }, { "format-patch", cmd_format_patch, RUN_SETUP }, - { "fsck", cmd_fsck, RUN_SETUP | BLOCK_ON_GVFS_REPO}, + { "fsck", cmd_fsck, RUN_SETUP | BLOCK_ON_VFS_ENABLED }, { "fsck-objects", cmd_fsck, RUN_SETUP }, { "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP }, { "gc", cmd_gc, RUN_SETUP }, From 0e69b1e9ba08296ca8330f06026aa3fa71332997 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Thu, 13 Mar 2025 13:31:50 +0000 Subject: [PATCH 4/6] git.c: permit prune cmd in Scalar repos Loosen the blocking of the `prune` command from all "GVFS repos" (those that have `core.gvfs` set) to only those that actually use the virtual file system (VFS for Git only). This allows for `prune` to be used in Scalar clones. Signed-off-by: Matthew John Cheetham --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.c b/git.c index 059a724ca50c9c..b809745b943309 100644 --- a/git.c +++ b/git.c @@ -672,7 +672,7 @@ static struct cmd_struct commands[] = { { "pack-refs", cmd_pack_refs, RUN_SETUP }, { "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT }, { "pickaxe", cmd_blame, RUN_SETUP }, - { "prune", cmd_prune, RUN_SETUP | BLOCK_ON_GVFS_REPO}, + { "prune", cmd_prune, RUN_SETUP | BLOCK_ON_VFS_ENABLED }, { "prune-packed", cmd_prune_packed, RUN_SETUP }, { "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE }, { "push", cmd_push, RUN_SETUP }, From 9df7c2a295618c5868d5835163cf5d8fab881333 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Thu, 6 Mar 2025 11:16:04 +0000 Subject: [PATCH 5/6] worktree: remove special case GVFS cmd blocking Replace the special casing of the `worktree` command being blocked on VFS-enabled repos with the new `BLOCK_ON_VFS_ENABLED` flag. Signed-off-by: Matthew John Cheetham --- builtin/worktree.c | 7 ------- git.c | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index d23036578f4e51..40c163571a149f 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -1451,13 +1451,6 @@ int cmd_worktree(int ac, git_config(git_worktree_config, NULL); - /* - * git-worktree is special-cased to work in Scalar repositories - * even when they use the GVFS Protocol. - */ - if (core_gvfs & GVFS_USE_VIRTUAL_FILESYSTEM) - die("'git %s' is not supported on a GVFS repo", "worktree"); - if (!prefix) prefix = ""; diff --git a/git.c b/git.c index b809745b943309..dde57ae33749e7 100644 --- a/git.c +++ b/git.c @@ -726,7 +726,7 @@ static struct cmd_struct commands[] = { { "verify-tag", cmd_verify_tag, RUN_SETUP }, { "version", cmd_version }, { "whatchanged", cmd_whatchanged, RUN_SETUP }, - { "worktree", cmd_worktree, RUN_SETUP }, + { "worktree", cmd_worktree, RUN_SETUP | BLOCK_ON_VFS_ENABLED }, { "write-tree", cmd_write_tree, RUN_SETUP }, }; From 84f94591d6d3a2a379dd24fcc40c30b90b9b2af3 Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Wed, 26 Mar 2025 10:31:38 +0000 Subject: [PATCH 6/6] builtin/repack.c: emit warning when shared cache is present Emit a warning message when the `gvfs.sharedCache` option is set that the `repack` command will not perform repacking on the shared cache. In the future we can teach `repack` to operate on the shared cache, at which point we can drop this commit. Signed-off-by: Matthew John Cheetham --- builtin/repack.c | 6 ++++++ gvfs.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/builtin/repack.c b/builtin/repack.c index 68c5c5c3ff10db..9c267bc1446483 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -24,6 +24,7 @@ #include "pack-bitmap.h" #include "refs.h" #include "list-objects-filter-options.h" +#include "gvfs.h" #define ALL_INTO_ONE 1 #define LOOSEN_UNREACHABLE 2 @@ -1177,6 +1178,7 @@ int cmd_repack(int argc, struct tempfile *refs_snapshot = NULL; int i, ext, ret; int show_progress; + const char *tmp_obj_dir = NULL; /* variables to be filled by option parsing */ int delete_redundant = 0; @@ -1301,6 +1303,10 @@ int cmd_repack(int argc, write_bitmaps = 0; } + if (gvfs_config_is_set(GVFS_ANY_MASK) && + !git_config_get_value("gvfs.sharedcache", &tmp_obj_dir)) + warning(_("shared object cache is configured but will not be repacked")); + if (write_midx && write_bitmaps) { struct strbuf path = STRBUF_INIT; diff --git a/gvfs.h b/gvfs.h index 99c5205aa043d7..07cb0722e44a03 100644 --- a/gvfs.h +++ b/gvfs.h @@ -30,6 +30,8 @@ #define GVFS_BLOCK_FILTERS_AND_EOL_CONVERSIONS (1 << 6) #define GVFS_PREFETCH_DURING_FETCH (1 << 7) +#define GVFS_ANY_MASK 0xFFFFFFFF + void gvfs_load_config_value(const char *value); int gvfs_config_is_set(int mask);