зеркало из https://github.com/microsoft/git.git
maintenance: care about gvfs.sharedCache config
For Scalar and VFS for Git, we use an alternate as a shared object cache. We need to enable the maintenance builtin to work on that shared object cache, especially in the background. 'scalar run <task>' would set GIT_OBJECT_DIRECTORY to handle this. We set GIT_OBJECT_DIRECTORY based on the gvfs.sharedCache config, but we also need the checks in pack_loose() to look at that object directory instead of the current ODB's. Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
This commit is contained in:
Родитель
7a2faf21ca
Коммит
2864f7cbfd
21
builtin/gc.c
21
builtin/gc.c
|
@ -989,6 +989,8 @@ static int write_loose_object_to_stdin(const struct object_id *oid,
|
||||||
return ++(d->count) > d->batch_size;
|
return ++(d->count) > d->batch_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *object_dir = NULL;
|
||||||
|
|
||||||
static int pack_loose(struct maintenance_run_opts *opts)
|
static int pack_loose(struct maintenance_run_opts *opts)
|
||||||
{
|
{
|
||||||
struct repository *r = the_repository;
|
struct repository *r = the_repository;
|
||||||
|
@ -996,11 +998,14 @@ static int pack_loose(struct maintenance_run_opts *opts)
|
||||||
struct write_loose_object_data data;
|
struct write_loose_object_data data;
|
||||||
struct child_process pack_proc = CHILD_PROCESS_INIT;
|
struct child_process pack_proc = CHILD_PROCESS_INIT;
|
||||||
|
|
||||||
|
if (!object_dir)
|
||||||
|
object_dir = r->objects->odb->path;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not start pack-objects process
|
* Do not start pack-objects process
|
||||||
* if there are no loose objects.
|
* 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,
|
bail_on_loose,
|
||||||
NULL, NULL, NULL))
|
NULL, NULL, NULL))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1010,7 +1015,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
|
||||||
strvec_push(&pack_proc.args, "pack-objects");
|
strvec_push(&pack_proc.args, "pack-objects");
|
||||||
if (opts->quiet)
|
if (opts->quiet)
|
||||||
strvec_push(&pack_proc.args, "--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;
|
pack_proc.in = -1;
|
||||||
|
|
||||||
|
@ -1023,7 +1028,7 @@ static int pack_loose(struct maintenance_run_opts *opts)
|
||||||
data.count = 0;
|
data.count = 0;
|
||||||
data.batch_size = 50000;
|
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,
|
write_loose_object_to_stdin,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1433,6 +1438,16 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
|
||||||
if (argc != 0)
|
if (argc != 0)
|
||||||
usage_with_options(builtin_maintenance_run_usage,
|
usage_with_options(builtin_maintenance_run_usage,
|
||||||
builtin_maintenance_run_options);
|
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);
|
return maintenance_run_tasks(&opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче