Skip to content

Commit 908751c

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 25b2697 + 4cb8f09 commit 908751c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

builtin/gc.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,18 +1059,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
10591059
return ++(d->count) > d->batch_size;
10601060
}
10611061

1062+
static const char *object_dir = NULL;
1063+
10621064
static int pack_loose(struct maintenance_run_opts *opts)
10631065
{
10641066
struct repository *r = the_repository;
10651067
int result = 0;
10661068
struct write_loose_object_data data;
10671069
struct child_process pack_proc = CHILD_PROCESS_INIT;
10681070

1071+
if (!object_dir)
1072+
object_dir = r->objects->odb->path;
1073+
10691074
/*
10701075
* Do not start pack-objects process
10711076
* if there are no loose objects.
10721077
*/
1073-
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
1078+
if (!for_each_loose_file_in_objdir(object_dir,
10741079
bail_on_loose,
10751080
NULL, NULL, NULL))
10761081
return 0;
@@ -1080,7 +1085,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
10801085
strvec_push(&pack_proc.args, "pack-objects");
10811086
if (opts->quiet)
10821087
strvec_push(&pack_proc.args, "--quiet");
1083-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
1088+
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);
10841089

10851090
pack_proc.in = -1;
10861091

@@ -1093,7 +1098,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
10931098
data.count = 0;
10941099
data.batch_size = 50000;
10951100

1096-
for_each_loose_file_in_objdir(r->objects->odb->path,
1101+
for_each_loose_file_in_objdir(object_dir,
10971102
write_loose_object_to_stdin,
10981103
NULL,
10991104
NULL,
@@ -1471,6 +1476,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
14711476
{
14721477
int i;
14731478
struct maintenance_run_opts opts;
1479+
const char *tmp_obj_dir = NULL;
14741480
struct option builtin_maintenance_run_options[] = {
14751481
OPT_BOOL(0, "auto", &opts.auto_flag,
14761482
N_("run tasks based on the state of the repository")),
@@ -1504,6 +1510,18 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
15041510
if (argc != 0)
15051511
usage_with_options(builtin_maintenance_run_usage,
15061512
builtin_maintenance_run_options);
1513+
1514+
/*
1515+
* To enable the VFS for Git/Scalar shared object cache, use
1516+
* the gvfs.sharedcache config option to redirect the
1517+
* maintenance to that location.
1518+
*/
1519+
if (!git_config_get_value("gvfs.sharedcache", &tmp_obj_dir) &&
1520+
tmp_obj_dir) {
1521+
object_dir = xstrdup(tmp_obj_dir);
1522+
setenv(DB_ENVIRONMENT, object_dir, 1);
1523+
}
1524+
15071525
return maintenance_run_tasks(&opts);
15081526
}
15091527

0 commit comments

Comments
 (0)