Skip to content

Commit ef1780c

Browse files
mjcheethamdscho
authored andcommitted
Permit repack command in Scalar clones (#732)
Currently when the `core.gvfs` setting is set, several commands are outright blocked from running. Some of these commands, namely `repack` are actually OK to run in a Scalar clone, even if it uses the GVFS protocol (for Azure DevOps). Introduce a different blocking mechanism to only block commands when the virtual filesystem is being used, rather than as a broad block on any `core.gvfs` setting.
2 parents ceaf70e + 4e55278 commit ef1780c

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

builtin/repack.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "promisor-remote.h"
1616
#include "repack.h"
1717
#include "shallow.h"
18+
#include "gvfs.h"
1819

1920
#define ALL_INTO_ONE 1
2021
#define LOOSEN_UNREACHABLE 2
@@ -110,6 +111,7 @@ int cmd_repack(int argc,
110111
struct tempfile *refs_snapshot = NULL;
111112
int i, ret;
112113
int show_progress;
114+
const char *tmp_obj_dir = NULL;
113115

114116
/* variables to be filled by option parsing */
115117
struct repack_config_ctx config_ctx;
@@ -244,6 +246,10 @@ int cmd_repack(int argc,
244246
write_bitmaps = 0;
245247
}
246248

249+
if (gvfs_config_is_set(repo, GVFS_ANY_MASK) &&
250+
!repo_config_get_value(repo, "gvfs.sharedcache", &tmp_obj_dir))
251+
warning(_("shared object cache is configured but will not be repacked"));
252+
247253
if (write_midx && write_bitmaps) {
248254
struct strbuf path = STRBUF_INIT;
249255

builtin/worktree.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,13 +1451,6 @@ int cmd_worktree(int ac,
14511451

14521452
repo_config(the_repository, git_worktree_config, NULL);
14531453

1454-
/*
1455-
* git-worktree is special-cased to work in Scalar repositories
1456-
* even when they use the GVFS Protocol.
1457-
*/
1458-
if (gvfs_config_is_set(repo, GVFS_USE_VIRTUAL_FILESYSTEM))
1459-
die("'git %s' is not supported on a GVFS repo", "worktree");
1460-
14611454
if (!prefix)
14621455
prefix = "";
14631456

git.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define NO_PARSEOPT (1<<5) /* parse-options is not used */
3434
#define DEPRECATED (1<<6)
3535
#define BLOCK_ON_GVFS_REPO (1<<7) /* command not allowed in GVFS repos */
36+
#define BLOCK_ON_VFS_ENABLED (1<<8) /* command not allowed when virtual file system is used */
3637

3738
struct cmd_struct {
3839
const char *cmd;
@@ -568,6 +569,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
568569
if (!help && p->option & BLOCK_ON_GVFS_REPO && gvfs_config_is_set(repo, GVFS_BLOCK_COMMANDS))
569570
die("'git %s' is not supported on a GVFS repo", p->cmd);
570571

572+
if (!help && p->option & BLOCK_ON_VFS_ENABLED && gvfs_config_is_set(repo, GVFS_USE_VIRTUAL_FILESYSTEM))
573+
die("'git %s' is not supported when using the virtual file system", p->cmd);
574+
571575
if (run_pre_command_hook(the_repository, argv))
572576
die("pre-command hook aborted command");
573577

@@ -652,7 +656,7 @@ static struct cmd_struct commands[] = {
652656
{ "for-each-ref", cmd_for_each_ref, RUN_SETUP },
653657
{ "for-each-repo", cmd_for_each_repo, RUN_SETUP_GENTLY },
654658
{ "format-patch", cmd_format_patch, RUN_SETUP },
655-
{ "fsck", cmd_fsck, RUN_SETUP | BLOCK_ON_GVFS_REPO},
659+
{ "fsck", cmd_fsck, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
656660
{ "fsck-objects", cmd_fsck, RUN_SETUP },
657661
{ "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP },
658662
{ "gc", cmd_gc, RUN_SETUP },
@@ -696,7 +700,7 @@ static struct cmd_struct commands[] = {
696700
{ "pack-refs", cmd_pack_refs, RUN_SETUP },
697701
{ "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
698702
{ "pickaxe", cmd_blame, RUN_SETUP },
699-
{ "prune", cmd_prune, RUN_SETUP | BLOCK_ON_GVFS_REPO},
703+
{ "prune", cmd_prune, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
700704
{ "prune-packed", cmd_prune_packed, RUN_SETUP },
701705
{ "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE },
702706
{ "push", cmd_push, RUN_SETUP },
@@ -709,7 +713,7 @@ static struct cmd_struct commands[] = {
709713
{ "remote", cmd_remote, RUN_SETUP },
710714
{ "remote-ext", cmd_remote_ext, NO_PARSEOPT },
711715
{ "remote-fd", cmd_remote_fd, NO_PARSEOPT },
712-
{ "repack", cmd_repack, RUN_SETUP | BLOCK_ON_GVFS_REPO },
716+
{ "repack", cmd_repack, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
713717
{ "replace", cmd_replace, RUN_SETUP },
714718
{ "replay", cmd_replay, RUN_SETUP },
715719
{ "repo", cmd_repo, RUN_SETUP },
@@ -752,7 +756,7 @@ static struct cmd_struct commands[] = {
752756
#ifndef WITH_BREAKING_CHANGES
753757
{ "whatchanged", cmd_whatchanged, RUN_SETUP | DEPRECATED },
754758
#endif
755-
{ "worktree", cmd_worktree, RUN_SETUP | BLOCK_ON_GVFS_REPO },
759+
{ "worktree", cmd_worktree, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
756760
{ "write-tree", cmd_write_tree, RUN_SETUP },
757761
};
758762

gvfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct repository;
2929
#define GVFS_FETCH_SKIP_REACHABILITY_AND_UPLOADPACK (1 << 4)
3030
#define GVFS_BLOCK_FILTERS_AND_EOL_CONVERSIONS (1 << 6)
3131

32+
#define GVFS_ANY_MASK 0xFFFFFFFF
33+
3234
int gvfs_config_is_set(struct repository *r, int mask);
3335
int gvfs_virtualize_objects(struct repository *r);
3436

t/t0402-block-command-on-gvfs.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ not_with_gvfs fsck
2222
not_with_gvfs gc
2323
not_with_gvfs gc --auto
2424
not_with_gvfs prune
25-
not_with_gvfs repack
2625
not_with_gvfs submodule status
2726
not_with_gvfs update-index --index-version 2
2827
not_with_gvfs update-index --skip-worktree
@@ -36,4 +35,14 @@ test_expect_success 'test gc --auto succeeds when disabled via config' '
3635
git gc --auto
3736
'
3837

38+
test_expect_success 'test repack fails with VFS bit enabled' '
39+
test_config core.gvfs true &&
40+
test_must_fail git repack
41+
'
42+
43+
test_expect_success 'test repack succeeds with VFS bit disabled' '
44+
test_config core.gvfs 150 &&
45+
git repack
46+
'
47+
3948
test_done

0 commit comments

Comments
 (0)