From patchwork Fri Dec 3 13:34:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12655215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1816FC433F5 for ; Fri, 3 Dec 2021 13:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381130AbhLCNiU (ORCPT ); Fri, 3 Dec 2021 08:38:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381105AbhLCNiM (ORCPT ); Fri, 3 Dec 2021 08:38:12 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29D55C0613DD for ; Fri, 3 Dec 2021 05:34:43 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id 133so2418558wme.0 for ; Fri, 03 Dec 2021 05:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=b0RrJffSAoUtbuQrA9X8iAnoDmAsgu/iVcj3rdu+reU=; b=qEeMbd2F0CJRaDIdvciLIotTBQXPQt8b9ExeGerJOdbo/5kAeR0x5MG44zCLpUirSf kyWno2aYvfI4PSgczDuQZN5MxWIRmBY2AWCBgWfkRf+muthRwRORg5c4v2zWwiq3GUH2 rH0dwWNRuUreOnoJcxSB0FulOh3td9KZ4ZDnghDOCnsGdjomK4DjvU7PqNkwTQJ85rsA rlEitWXNf+YXDt7Xk3zP9VlBMunjM2DZAFXduEi9FV03L0z7P/b8Sc6cb8tL+8EUUQX1 AUMzbY/m1tD1KT+UysVfqBenykhgKws77GUNZ0Jp1wRBO3crjoB/q5tqlBWeHnRYtelY ydkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=b0RrJffSAoUtbuQrA9X8iAnoDmAsgu/iVcj3rdu+reU=; b=b/sKVJkidQ7ThEtpOEatflq9AXDSSjLq+m1GT5dvVZu+Lm1808GvIk5M9Rj4sTCLYZ BuZHFb6rJKkvD14TGMyXe0AxNWVWjidsU/M0gV/ZIlPunNll6ern5a4g6uWov+DxasYv k8MR7EAdmcqOx+KvzUA6mWTRjPES9bQgKeM3o8aUnWJJh3Z4U0cXCsNpGhmPbeBpNPtq HNSh3HwgtC3xi/VdK14/Ro6I+HkMyn/x2UzP0PwGwcXbMsRzFZptwNn78DP+lJtCjGyW 1A2o70Hrc3SM6KyXmfkXS0/1pOa+hQ8wE7m5d0d9Jt9e0eFQln0e5AR1LWbW5yemKTSl vG3g== X-Gm-Message-State: AOAM532HQ4lNpn0EcRVhjUx/vNJBAqA+JRgoZUGcJLQJR/GIJtr+taF0 gxn/jp1WvoXZ31jxquj59xppiKXTRY8= X-Google-Smtp-Source: ABdhPJx3Fn2Yx8/5f/yiLfysDyI3jRTW4Qrbunj3vsdCimBfqOw910RLjTlMHzWR6g+zegyYUaau2Q== X-Received: by 2002:a7b:ce16:: with SMTP id m22mr14980667wmc.137.1638538481589; Fri, 03 Dec 2021 05:34:41 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f7sm6438146wmg.6.2021.12.03.05.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 05:34:41 -0800 (PST) Message-Id: <15e649a173429732974c5c5d795565f360984095.1638538470.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 03 Dec 2021 13:34:25 +0000 Subject: [PATCH v10 11/15] scalar: implement the `run` command Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Theodore Ts'o , Matt Rogers , Johannes Schindelin , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Note: this subcommand is provided primarily for backwards-compatibility, for existing Scalar uses. It is mostly just a shim for `git maintenance`, mapping task names from the way Scalar called them to the way Git calls them. The reason why those names differ? The background maintenance was first implemented in Scalar, and when it was contributed as a patch series implementing the `git maintenance` command, reviewers suggested better names, those suggestions were accepted before the patches were integrated into core Git. Signed-off-by: Derrick Stolee Signed-off-by: Johannes Schindelin --- contrib/scalar/scalar.c | 64 +++++++++++++++++++++++++++++++++++++++ contrib/scalar/scalar.txt | 19 ++++++++++++ 2 files changed, 83 insertions(+) diff --git a/contrib/scalar/scalar.c b/contrib/scalar/scalar.c index 61b66e48aa8..fa900e4373f 100644 --- a/contrib/scalar/scalar.c +++ b/contrib/scalar/scalar.c @@ -484,6 +484,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 []\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; @@ -556,6 +619,7 @@ static struct { { "list", cmd_list }, { "register", cmd_register }, { "unregister", cmd_unregister }, + { "run", cmd_run }, { NULL, NULL}, }; diff --git a/contrib/scalar/scalar.txt b/contrib/scalar/scalar.txt index 56f744a4aa9..39143b08324 100644 --- a/contrib/scalar/scalar.txt +++ b/contrib/scalar/scalar.txt @@ -12,6 +12,7 @@ scalar clone [--single-branch] [--branch ] [--full-clone] [] scalar unregister [] +scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [] DESCRIPTION ----------- @@ -98,6 +99,24 @@ unregister []:: 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 ) []:: + 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].