From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: jrnieder@gmail.com, jonathantanmy@google.com, sluongng@gmail.com,
congdanhqx@gmail.com, Derrick Stolee <derrickstolee@github.com>,
Derrick Stolee <dstolee@microsoft.com>
Subject: [PATCH 6/7] maintenance: recommended schedule in register/start
Date: Fri, 04 Sep 2020 15:42:05 +0000 [thread overview]
Message-ID: <8a285e00e66d697f93f868e8e59bf472c29a78ec.1599234127.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.724.git.1599234126.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>
The 'git maintenance (register|start)' subcommands add the current
repository to the global Git config so maintenance will operate on that
repository. It does not specify what maintenance should occur or how
often.
If a user sets any 'maintenance.<task>.schedule' config value, then
they have chosen a specific schedule for themselves and Git should
respect that.
However, in an effort to recommend a good schedule for repositories of
all sizes, set new config values for recommended tasks that are safe to
run in the background while users run foreground Git commands. These
commands are generally everything but the 'gc' task.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
Documentation/git-maintenance.txt | 6 ++++
builtin/gc.c | 46 +++++++++++++++++++++++++++++++
t/t7900-maintenance.sh | 16 +++++++++++
3 files changed, 68 insertions(+)
diff --git a/Documentation/git-maintenance.txt b/Documentation/git-maintenance.txt
index 7f8c279fe8..364b3e32bf 100644
--- a/Documentation/git-maintenance.txt
+++ b/Documentation/git-maintenance.txt
@@ -37,6 +37,12 @@ register::
`maintenance.<task>.schedule`. The tasks that are enabled are safe
for running in the background without disrupting foreground
processes.
++
+If your repository has no 'maintenance.<task>.schedule' configuration
+values set, then Git will set configuration values to some recommended
+settings. These settings disable foreground maintenance while performing
+maintenance tasks in the background that will not interrupt foreground Git
+operations.
run::
Run one or more maintenance tasks. If one or more `--task` options
diff --git a/builtin/gc.c b/builtin/gc.c
index 9914417e25..5f253d3458 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1408,6 +1408,49 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
return maintenance_run_tasks(&opts);
}
+static int has_schedule_config(void)
+{
+ int i, found = 0;
+ struct strbuf config_name = STRBUF_INIT;
+ size_t prefix;
+
+ strbuf_addstr(&config_name, "maintenance.");
+ prefix = config_name.len;
+
+ for (i = 0; !found && i < TASK__COUNT; i++) {
+ char *value;
+
+ strbuf_setlen(&config_name, prefix);
+ strbuf_addf(&config_name, "%s.schedule", tasks[i].name);
+
+ if (!git_config_get_string(config_name.buf, &value)) {
+ found = 1;
+ FREE_AND_NULL(value);
+ }
+ }
+
+ strbuf_release(&config_name);
+ return found;
+}
+
+static void set_recommended_schedule(void)
+{
+ git_config_set("maintenance.auto", "false");
+ git_config_set("maintenance.gc.enabled", "false");
+
+ git_config_set("maintenance.prefetch.enabled", "true");
+ git_config_set("maintenance.prefetch.schedule", "hourly");
+
+ git_config_set("maintenance.commit-graph.enabled", "true");
+ git_config_set("maintenance.commit-graph.schedule", "hourly");
+
+ git_config_set("maintenance.loose-objects.enabled", "true");
+ git_config_set("maintenance.loose-objects.schedule", "daily");
+
+ git_config_set("maintenance.incremental-repack.enabled", "true");
+ git_config_set("maintenance.incremental-repack.schedule", "daily");
+}
+
static int maintenance_register(void)
{
struct child_process config_set = CHILD_PROCESS_INIT;
@@ -1417,6 +1460,9 @@ static int maintenance_register(void)
if (!the_repository || !the_repository->gitdir)
return 0;
+ if (!has_schedule_config())
+ set_recommended_schedule();
+
config_get.git_cmd = 1;
strvec_pushl(&config_get.args, "config", "--global", "--get", "maintenance.repo",
the_repository->worktree ? the_repository->worktree
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 8803fcf621..5a31f3925b 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -309,7 +309,23 @@ test_expect_success 'register and unregister' '
git config --global --add maintenance.repo /existing1 &&
git config --global --add maintenance.repo /existing2 &&
git config --global --get-all maintenance.repo >before &&
+
+ # We still have maintenance.<task>.schedule config set,
+ # so this does not update the local schedule
+ git maintenance register &&
+ test_must_fail git config maintenance.auto &&
+
+ # Clear previous maintenance.<task>.schedule values
+ for task in loose-objects commit-graph incremental-repack
+ do
+ git config --unset maintenance.$task.schedule || return 1
+ done &&
git maintenance register &&
+ test_cmp_config false maintenance.auto &&
+ test_cmp_config false maintenance.gc.enabled &&
+ test_cmp_config true maintenance.prefetch.enabled &&
+ test_cmp_config hourly maintenance.commit-graph.schedule &&
+ test_cmp_config daily maintenance.incremental-repack.schedule &&
git config --global --get-all maintenance.repo >actual &&
cp before after &&
pwd >>after &&
--
gitgitgadget
next prev parent reply other threads:[~2020-09-04 15:43 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 15:41 [PATCH 0/7] Maintenance III: Background maintenance Derrick Stolee via GitGitGadget
2020-09-04 15:42 ` [PATCH 1/7] maintenance: optionally skip --auto process Derrick Stolee via GitGitGadget
2020-09-04 15:42 ` [PATCH 2/7] maintenance: add --schedule option and config Derrick Stolee via GitGitGadget
2020-09-08 13:07 ` Đoàn Trần Công Danh
2020-09-09 12:14 ` Derrick Stolee
2020-09-04 15:42 ` [PATCH 3/7] for-each-repo: run subcommands on configured repos Derrick Stolee via GitGitGadget
2020-09-04 15:42 ` [PATCH 4/7] maintenance: add [un]register subcommands Derrick Stolee via GitGitGadget
2020-09-04 15:42 ` [PATCH 5/7] maintenance: add start/stop subcommands Derrick Stolee via GitGitGadget
2020-09-08 6:29 ` SZEDER Gábor
2020-09-08 12:43 ` Derrick Stolee
2020-09-08 19:31 ` Junio C Hamano
2020-09-04 15:42 ` Derrick Stolee via GitGitGadget [this message]
2020-09-04 15:42 ` [PATCH 7/7] maintenance: add troubleshooting guide to docs Derrick Stolee via GitGitGadget
2020-09-11 17:49 ` [PATCH v2 0/7] Maintenance III: Background maintenance Derrick Stolee via GitGitGadget
2020-09-11 17:49 ` [PATCH v2 1/7] maintenance: optionally skip --auto process Derrick Stolee via GitGitGadget
2020-09-11 17:49 ` [PATCH v2 2/7] maintenance: add --schedule option and config Derrick Stolee via GitGitGadget
2020-09-11 17:49 ` [PATCH v2 3/7] for-each-repo: run subcommands on configured repos Derrick Stolee via GitGitGadget
2020-09-11 17:49 ` [PATCH v2 4/7] maintenance: add [un]register subcommands Derrick Stolee via GitGitGadget
2020-09-17 14:05 ` Đoàn Trần Công Danh
2020-09-11 17:49 ` [PATCH v2 5/7] maintenance: add start/stop subcommands Derrick Stolee via GitGitGadget
2020-09-11 17:49 ` [PATCH v2 6/7] maintenance: recommended schedule in register/start Derrick Stolee via GitGitGadget
2020-09-29 19:48 ` Martin Ågren
2020-09-30 20:11 ` Derrick Stolee
2020-10-01 20:38 ` Derrick Stolee
2020-10-02 0:38 ` Đoàn Trần Công Danh
2020-10-02 1:55 ` Derrick Stolee
2020-10-05 13:16 ` Đoàn Trần Công Danh
2020-10-05 18:17 ` Derrick Stolee
2020-09-11 17:49 ` [PATCH v2 7/7] maintenance: add troubleshooting guide to docs Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 0/7] Maintenance III: Background maintenance Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 1/7] maintenance: optionally skip --auto process Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 2/7] maintenance: add --schedule option and config Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 3/7] for-each-repo: run subcommands on configured repos Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 4/7] maintenance: add [un]register subcommands Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 5/7] maintenance: add start/stop subcommands Derrick Stolee via GitGitGadget
2020-10-05 12:57 ` [PATCH v3 6/7] maintenance: use default schedule if not configured Derrick Stolee via GitGitGadget
2020-10-05 19:57 ` Martin Ågren
2020-10-08 13:32 ` Derrick Stolee
2020-10-05 12:57 ` [PATCH v3 7/7] maintenance: add troubleshooting guide to docs Derrick Stolee via GitGitGadget
2020-10-15 17:21 ` [PATCH v4 0/8] Maintenance III: Background maintenance Derrick Stolee via GitGitGadget
2020-10-15 17:21 ` [PATCH v4 1/8] maintenance: optionally skip --auto process Derrick Stolee via GitGitGadget
2020-10-15 17:21 ` [PATCH v4 2/8] maintenance: add --schedule option and config Derrick Stolee via GitGitGadget
2021-02-09 14:06 ` Ævar Arnfjörð Bjarmason
2021-02-09 16:54 ` Derrick Stolee
2021-05-10 12:16 ` Ævar Arnfjörð Bjarmason
2021-05-10 18:42 ` Junio C Hamano
2020-10-15 17:21 ` [PATCH v4 3/8] for-each-repo: run subcommands on configured repos Derrick Stolee via GitGitGadget
2021-05-03 16:10 ` Andrzej Hunt
2021-05-03 17:01 ` Eric Sunshine
2021-05-03 19:26 ` Eric Sunshine
2021-05-03 19:43 ` Derrick Stolee
2020-10-15 17:22 ` [PATCH v4 4/8] maintenance: add [un]register subcommands Derrick Stolee via GitGitGadget
2020-10-15 17:22 ` [PATCH v4 5/8] maintenance: add start/stop subcommands Derrick Stolee via GitGitGadget
2020-12-09 18:51 ` Josh Steadmon
2020-12-09 19:16 ` Josh Steadmon
2020-12-09 21:59 ` Derrick Stolee
2020-12-10 0:13 ` Junio C Hamano
2020-12-10 1:52 ` Derrick Stolee
2020-12-10 6:54 ` Junio C Hamano
2020-10-15 17:22 ` [PATCH v4 6/8] maintenance: create maintenance.strategy config Derrick Stolee via GitGitGadget
2020-10-15 17:22 ` [PATCH v4 7/8] maintenance: use 'incremental' strategy by default Derrick Stolee via GitGitGadget
2020-10-15 17:22 ` [PATCH v4 8/8] maintenance: add troubleshooting guide to docs Derrick Stolee via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a285e00e66d697f93f868e8e59bf472c29a78ec.1599234127.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=congdanhqx@gmail.com \
--cc=derrickstolee@github.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.com \
--cc=jrnieder@gmail.com \
--cc=sluongng@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).