Skip to content

Commit

Permalink
Merge pull request git-for-windows#301: Update 'git maintenance' to m…
Browse files Browse the repository at this point in the history
…atch 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.
  • Loading branch information
derrickstolee authored and jeffhostetler committed Mar 16, 2021
2 parents 74febf0 + 8e80f99 commit 79a65a6
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,18 +1012,23 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
return ++(d->count) > d->batch_size;
}

static const char *object_dir = NULL;

static int pack_loose(struct maintenance_run_opts *opts)
{
struct repository *r = the_repository;
int result = 0;
struct write_loose_object_data data;
struct child_process pack_proc = CHILD_PROCESS_INIT;

if (!object_dir)
object_dir = r->objects->odb->path;

/*
* Do not start pack-objects process
* if there are no loose objects.
*/
if (!for_each_loose_file_in_objdir(r->objects->odb->path,
if (!for_each_loose_file_in_objdir(object_dir,
bail_on_loose,
NULL, NULL, NULL))
return 0;
Expand All @@ -1033,7 +1038,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
strvec_push(&pack_proc.args, "pack-objects");
if (opts->quiet)
strvec_push(&pack_proc.args, "--quiet");
strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path);
strvec_pushf(&pack_proc.args, "%s/pack/loose", object_dir);

pack_proc.in = -1;

Expand All @@ -1046,7 +1051,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
data.count = 0;
data.batch_size = 50000;

for_each_loose_file_in_objdir(r->objects->odb->path,
for_each_loose_file_in_objdir(object_dir,
write_loose_object_to_stdin,
NULL,
NULL,
Expand Down Expand Up @@ -1462,6 +1467,16 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
if (argc != 0)
usage_with_options(builtin_maintenance_run_usage,
builtin_maintenance_run_options);

/*
* To enable the VFS for Git/Scalar shared object cache, use
* the gvfs.sharedcache config option to redirect the
* maintenance to that location.
*/
if (!git_config_get_value("gvfs.sharedcache", &object_dir) &&
object_dir)
setenv(DB_ENVIRONMENT, object_dir, 1);

return maintenance_run_tasks(&opts);
}

Expand Down

0 comments on commit 79a65a6

Please sign in to comment.