Skip to content

Commit 0c988ed

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 be56709 + 26503a2 commit 0c988ed

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
@@ -24,6 +24,7 @@
2424
#include "pack-bitmap.h"
2525
#include "refs.h"
2626
#include "list-objects-filter-options.h"
27+
#include "gvfs.h"
2728

2829
#define ALL_INTO_ONE 1
2930
#define LOOSEN_UNREACHABLE 2
@@ -1177,6 +1178,7 @@ int cmd_repack(int argc,
11771178
struct tempfile *refs_snapshot = NULL;
11781179
int i, ext, ret;
11791180
int show_progress;
1181+
const char *tmp_obj_dir = NULL;
11801182

11811183
/* variables to be filled by option parsing */
11821184
int delete_redundant = 0;
@@ -1301,6 +1303,10 @@ int cmd_repack(int argc,
13011303
write_bitmaps = 0;
13021304
}
13031305

1306+
if (gvfs_config_is_set(GVFS_ANY_MASK) &&
1307+
!git_config_get_value("gvfs.sharedcache", &tmp_obj_dir))
1308+
warning(_("shared object cache is configured but will not be repacked"));
1309+
13041310
if (write_midx && write_bitmaps) {
13051311
struct strbuf path = STRBUF_INIT;
13061312

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
git_config(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 (core_gvfs & 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
@@ -32,6 +32,7 @@
3232
#define DELAY_PAGER_CONFIG (1<<4)
3333
#define NO_PARSEOPT (1<<5) /* parse-options is not used */
3434
#define BLOCK_ON_GVFS_REPO (1<<6) /* command not allowed in GVFS repos */
35+
#define BLOCK_ON_VFS_ENABLED (1<<7) /* command not allowed when virtual file system is used */
3536

3637
struct cmd_struct {
3738
const char *cmd;
@@ -542,6 +543,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
542543
if (!help && p->option & BLOCK_ON_GVFS_REPO && gvfs_config_is_set(GVFS_BLOCK_COMMANDS))
543544
die("'git %s' is not supported on a GVFS repo", p->cmd);
544545

546+
if (!help && p->option & BLOCK_ON_VFS_ENABLED && gvfs_config_is_set(GVFS_USE_VIRTUAL_FILESYSTEM))
547+
die("'git %s' is not supported when using the virtual file system", p->cmd);
548+
545549
if (run_pre_command_hook(the_repository, argv))
546550
die("pre-command hook aborted command");
547551

@@ -625,7 +629,7 @@ static struct cmd_struct commands[] = {
625629
{ "for-each-ref", cmd_for_each_ref, RUN_SETUP },
626630
{ "for-each-repo", cmd_for_each_repo, RUN_SETUP_GENTLY },
627631
{ "format-patch", cmd_format_patch, RUN_SETUP },
628-
{ "fsck", cmd_fsck, RUN_SETUP | BLOCK_ON_GVFS_REPO},
632+
{ "fsck", cmd_fsck, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
629633
{ "fsck-objects", cmd_fsck, RUN_SETUP },
630634
{ "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP },
631635
{ "gc", cmd_gc, RUN_SETUP },
@@ -668,7 +672,7 @@ static struct cmd_struct commands[] = {
668672
{ "pack-refs", cmd_pack_refs, RUN_SETUP },
669673
{ "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
670674
{ "pickaxe", cmd_blame, RUN_SETUP },
671-
{ "prune", cmd_prune, RUN_SETUP | BLOCK_ON_GVFS_REPO},
675+
{ "prune", cmd_prune, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
672676
{ "prune-packed", cmd_prune_packed, RUN_SETUP },
673677
{ "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE },
674678
{ "push", cmd_push, RUN_SETUP },
@@ -681,7 +685,7 @@ static struct cmd_struct commands[] = {
681685
{ "remote", cmd_remote, RUN_SETUP },
682686
{ "remote-ext", cmd_remote_ext, NO_PARSEOPT },
683687
{ "remote-fd", cmd_remote_fd, NO_PARSEOPT },
684-
{ "repack", cmd_repack, RUN_SETUP | BLOCK_ON_GVFS_REPO },
688+
{ "repack", cmd_repack, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
685689
{ "replace", cmd_replace, RUN_SETUP },
686690
{ "replay", cmd_replay, RUN_SETUP },
687691
{ "rerere", cmd_rerere, RUN_SETUP },
@@ -722,7 +726,7 @@ static struct cmd_struct commands[] = {
722726
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
723727
{ "version", cmd_version },
724728
{ "whatchanged", cmd_whatchanged, RUN_SETUP },
725-
{ "worktree", cmd_worktree, RUN_SETUP },
729+
{ "worktree", cmd_worktree, RUN_SETUP | BLOCK_ON_VFS_ENABLED },
726730
{ "write-tree", cmd_write_tree, RUN_SETUP },
727731
};
728732

gvfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#define GVFS_BLOCK_FILTERS_AND_EOL_CONVERSIONS (1 << 6)
3131
#define GVFS_PREFETCH_DURING_FETCH (1 << 7)
3232

33+
#define GVFS_ANY_MASK 0xFFFFFFFF
34+
3335
void gvfs_load_config_value(const char *value);
3436
int gvfs_config_is_set(int mask);
3537

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)