Skip to content

Commit dc703e1

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 4a0c732 + 7012ab0 commit dc703e1

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
@@ -1151,18 +1151,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
11511151
return ++(d->count) > d->batch_size;
11521152
}
11531153

1154+
static const char *object_dir = NULL;
1155+
11541156
static int pack_loose(struct maintenance_run_opts *opts)
11551157
{
11561158
struct repository *r = the_repository;
11571159
int result = 0;
11581160
struct write_loose_object_data data;
11591161
struct child_process pack_proc = CHILD_PROCESS_INIT;
11601162

1163+
if (!object_dir)
1164+
object_dir = r->objects->odb->path;
1165+
11611166
/*
11621167
* Do not start pack-objects process
11631168
* if there are no loose objects.
11641169
*/
1165-
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
1170+
if (!for_each_loose_file_in_objdir(object_dir,
11661171
bail_on_loose,
11671172
NULL, NULL, NULL))
11681173
return 0;
@@ -1172,7 +1177,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
11721177
strvec_push(&pack_proc.args, "pack-objects");
11731178
if (opts->quiet)
11741179
strvec_push(&pack_proc.args, "--quiet");
1175-
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
1180+
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);
11761181

11771182
pack_proc.in = -1;
11781183

@@ -1191,7 +1196,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
11911196
data.count = 0;
11921197
data.batch_size = 50000;
11931198

1194-
for_each_loose_file_in_objdir(r->objects->odb->path,
1199+
for_each_loose_file_in_objdir(object_dir,
11951200
write_loose_object_to_stdin,
11961201
NULL,
11971202
NULL,
@@ -1581,6 +1586,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
15811586
int i;
15821587
struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
15831588
struct gc_config cfg = GC_CONFIG_INIT;
1589+
const char *tmp_obj_dir = NULL;
15841590
struct option builtin_maintenance_run_options[] = {
15851591
OPT_BOOL(0, "auto", &opts.auto_flag,
15861592
N_("run tasks based on the state of the repository")),
@@ -1618,6 +1624,17 @@ static int maintenance_run(int argc, const char **argv, const char *prefix,
16181624
usage_with_options(builtin_maintenance_run_usage,
16191625
builtin_maintenance_run_options);
16201626

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

0 commit comments

Comments
 (0)