Skip to content

Commit 8149c73

Browse files
derrickstoleedscho
authored andcommitted
Merge pull request #301: Update 'git maintenance' to match upstream
This PR updates our `vfs-2.29.0` branch's version of `git maintenance` to match the latest in upstream. Unfortunately, not all of these commits made it to the `2.30` release candidate, but there are more commits from the series making it in. They will cause a conflict in the `vfs-2.30.0` rebase, so merge them in here. This also includes the `fixup!` reverts of the earlier versions. Finally, I also noticed that we started depending on `git maintenance start` in Scalar for macOS, but we never checked that this worked with the shared object cache. It doesn't! 😨 The very tip commit of this PR includes logic to make `git maintenance run` care about `gvfs.sharedCache`. Functional test updates in Scalar will follow.
2 parents 32b2029 + 76d928d commit 8149c73

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

builtin/gc.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,12 +1338,19 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
13381338
return ++(d->count) > d->batch_size;
13391339
}
13401340

1341+
static const char *shared_object_dir = NULL;
1342+
13411343
static int pack_loose(struct maintenance_run_opts *opts)
13421344
{
13431345
struct repository *r = the_repository;
13441346
int result = 0;
13451347
struct write_loose_object_data data;
13461348
struct child_process pack_proc = CHILD_PROCESS_INIT;
1349+
const char *object_dir = r->objects->sources->path;
1350+
1351+
/* If set, use the shared object directory. */
1352+
if (shared_object_dir)
1353+
object_dir = shared_object_dir;
13471354

13481355
/*
13491356
* Do not start pack-objects process
@@ -1361,7 +1368,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
13611368
strvec_push(&pack_proc.args, "--quiet");
13621369
else
13631370
strvec_push(&pack_proc.args, "--no-quiet");
1364-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->sources->path);
1371+
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);
13651372

13661373
pack_proc.in = -1;
13671374

@@ -1832,11 +1839,12 @@ static int task_option_parse(const struct option *opt,
18321839
}
18331840

18341841
static int maintenance_run(int argc, const char **argv, const char *prefix,
1835-
struct repository *repo UNUSED)
1842+
struct repository *repo)
18361843
{
18371844
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
18381845
struct string_list selected_tasks = STRING_LIST_INIT_DUP;
18391846
struct gc_config cfg = GC_CONFIG_INIT;
1847+
const char *tmp_obj_dir = NULL;
18401848
struct option builtin_maintenance_run_options[] = {
18411849
OPT_BOOL(0, "auto", &opts.auto_flag,
18421850
N_("run tasks based on the state of the repository")),
@@ -1873,6 +1881,17 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
18731881
usage_with_options(builtin_maintenance_run_usage,
18741882
builtin_maintenance_run_options);
18751883

1884+
/*
1885+
* To enable the VFS for Git/Scalar shared object cache, use
1886+
* the gvfs.sharedcache config option to redirect the
1887+
* maintenance to that location.
1888+
*/
1889+
if (!repo_config_get_value(repo, "gvfs.sharedcache", &tmp_obj_dir) &&
1890+
tmp_obj_dir) {
1891+
shared_object_dir = xstrdup(tmp_obj_dir);
1892+
setenv(DB_ENVIRONMENT, shared_object_dir, 1);
1893+
}
1894+
18761895
ret = maintenance_run_tasks(&opts, &cfg);
18771896

18781897
string_list_clear(&selected_tasks, 0);

0 commit comments

Comments
 (0)