Skip to content

Commit fad34df

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 31e69d3 + 053b8a0 commit fad34df

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

builtin/gc.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,18 +1154,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
11541154
return ++(d->count) > d->batch_size;
11551155
}
11561156

1157+
static const char *object_dir = NULL;
1158+
11571159
static int pack_loose(struct maintenance_run_opts *opts)
11581160
{
11591161
struct repository *r = the_repository;
11601162
int result = 0;
11611163
struct write_loose_object_data data;
11621164
struct child_process pack_proc = CHILD_PROCESS_INIT;
11631165

1166+
if (!object_dir)
1167+
object_dir = r->objects->odb->path;
1168+
11641169
/*
11651170
* Do not start pack-objects process
11661171
* if there are no loose objects.
11671172
*/
1168-
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
1173+
if (!for_each_loose_file_in_objdir(object_dir,
11691174
bail_on_loose,
11701175
NULL, NULL, NULL))
11711176
return 0;
@@ -1175,7 +1180,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
11751180
strvec_push(&pack_proc.args, "pack-objects");
11761181
if (opts->quiet)
11771182
strvec_push(&pack_proc.args, "--quiet");
1178-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
1183+
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);
11791184

11801185
pack_proc.in = -1;
11811186

@@ -1194,7 +1199,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
11941199
data.count = 0;
11951200
data.batch_size = 50000;
11961201

1197-
for_each_loose_file_in_objdir(r->objects->odb->path,
1202+
for_each_loose_file_in_objdir(object_dir,
11981203
write_loose_object_to_stdin,
11991204
NULL,
12001205
NULL,
@@ -1584,6 +1589,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
15841589
int i;
15851590
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
15861591
struct gc_config cfg = GC_CONFIG_INIT;
1592+
const char *tmp_obj_dir = NULL;
15871593
struct option builtin_maintenance_run_options[] = {
15881594
OPT_BOOL(0, "auto", &opts.auto_flag,
15891595
N_("run tasks based on the state of the repository")),
@@ -1621,6 +1627,17 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
16211627
usage_with_options(builtin_maintenance_run_usage,
16221628
builtin_maintenance_run_options);
16231629

1630+
/*
1631+
* To enable the VFS for Git/Scalar shared object cache, use
1632+
* the gvfs.sharedcache config option to redirect the
1633+
* maintenance to that location.
1634+
*/
1635+
if (!git_config_get_value("gvfs.sharedcache", &tmp_obj_dir) &&
1636+
tmp_obj_dir) {
1637+
object_dir = xstrdup(tmp_obj_dir);
1638+
setenv(DB_ENVIRONMENT, object_dir, 1);
1639+
}
1640+
16241641
ret = maintenance_run_tasks(&opts, &cfg);
16251642
gc_config_release(&cfg);
16261643
return ret;

0 commit comments

Comments
 (0)