Skip to content

Commit aaa1095

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 7ecb167 + de58eef commit aaa1095

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
@@ -1060,18 +1060,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
10601060
return ++(d->count) > d->batch_size;
10611061
}
10621062

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

1072+
if (!object_dir)
1073+
object_dir = r->objects->odb->path;
1074+
10701075
/*
10711076
* Do not start pack-objects process
10721077
* if there are no loose objects.
10731078
*/
1074-
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
1079+
if (!for_each_loose_file_in_objdir(object_dir,
10751080
bail_on_loose,
10761081
NULL, NULL, NULL))
10771082
return 0;
@@ -1081,7 +1086,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
10811086
strvec_push(&pack_proc.args, "pack-objects");
10821087
if (opts->quiet)
10831088
strvec_push(&pack_proc.args, "--quiet");
1084-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
1089+
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);
10851090

10861091
pack_proc.in = -1;
10871092

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

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

0 commit comments

Comments
 (0)