@@ -483,6 +483,69 @@ static int cmd_register(int argc, const char **argv)
return register_dir();
}
+static int cmd_run(int argc, const char **argv)
+{
+ struct option options[] = {
+ OPT_END(),
+ };
+ struct {
+ const char *arg, *task;
+ } tasks[] = {
+ { "config", NULL },
+ { "commit-graph", "commit-graph" },
+ { "fetch", "prefetch" },
+ { "loose-objects", "loose-objects" },
+ { "pack-files", "incremental-repack" },
+ { NULL, NULL }
+ };
+ struct strbuf buf = STRBUF_INIT;
+ const char *usagestr[] = { NULL, NULL };
+ int i;
+
+ strbuf_addstr(&buf, N_("scalar run <task> [<enlistment>]\nTasks:\n"));
+ for (i = 0; tasks[i].arg; i++)
+ strbuf_addf(&buf, "\t%s\n", tasks[i].arg);
+ usagestr[0] = buf.buf;
+
+ argc = parse_options(argc, argv, NULL, options,
+ usagestr, 0);
+
+ if (!argc)
+ usage_with_options(usagestr, options);
+
+ if (!strcmp("all", argv[0])) {
+ i = -1;
+ } else {
+ for (i = 0; tasks[i].arg && strcmp(tasks[i].arg, argv[0]); i++)
+ ; /* keep looking for the task */
+
+ if (i > 0 && !tasks[i].arg) {
+ error(_("no such task: '%s'"), argv[0]);
+ usage_with_options(usagestr, options);
+ }
+ }
+
+ argc--;
+ argv++;
+ setup_enlistment_directory(argc, argv, usagestr, options, NULL);
+ strbuf_release(&buf);
+
+ if (i == 0)
+ return register_dir();
+
+ if (i > 0)
+ return run_git("maintenance", "run",
+ "--task", tasks[i].task, NULL);
+
+ if (register_dir())
+ return -1;
+ for (i = 1; tasks[i].arg; i++)
+ if (run_git("maintenance", "run",
+ "--task", tasks[i].task, NULL))
+ return -1;
+ return 0;
+}
+
static int remove_deleted_enlistment(struct strbuf *path)
{
int res = 0;
@@ -555,6 +618,7 @@ static struct {
{ "list", cmd_list },
{ "register", cmd_register },
{ "unregister", cmd_unregister },
+ { "run", cmd_run },
{ NULL, NULL},
};
@@ -12,6 +12,7 @@ scalar clone [--single-branch] [--branch <main-branch>] [--full-clone] <url> [<e
scalar list
scalar register [<enlistment>]
scalar unregister [<enlistment>]
+scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>]
DESCRIPTION
-----------
@@ -97,6 +98,24 @@ unregister [<enlistment>]::
Remove the specified repository from the list of repositories
registered with Scalar and stop the scheduled background maintenance.
+Run
+~~~
+
+scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>]::
+ Run the given maintenance task (or all tasks, if `all` was specified).
+ Except for `all` and `config`, this subcommand simply hands off to
+ linkgit:git-maintenance[1] (mapping `fetch` to `prefetch` and
+ `pack-files` to `incremental-repack`).
++
+These tasks are run automatically as part of the scheduled maintenance,
+as soon as the repository is registered with Scalar. It should therefore
+not be necessary to run this subcommand manually.
++
+The `config` task is specific to Scalar and configures all those
+opinionated default settings that make Git work more efficiently with
+large repositories. As this task is run as part of `scalar clone`
+automatically, explicit invocations of this task are rarely needed.
+
SEE ALSO
--------
linkgit:git-clone[1], linkgit:git-maintenance[1].