From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, johannes.schindelin@gmx.de,
Patrick Steinhardt <ps@pks.im>, Derrick Stolee <stolee@gmail.com>
Subject: [PATCH v2 0/4] scalar: add --no-maintenance option
Date: Mon, 05 May 2025 15:27:20 +0000 [thread overview]
Message-ID: <pull.1913.v2.git.1746458844.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1913.git.1746008680.gitgitgadget@gmail.com>
These patches add a new --no-maintenance option to the scalar register and
scalar clone commands. My motivation is based on setting up Scalar clones in
automated environments that set up a repo onto a disk image for use later.
If background maintenance runs during later setup steps, then this
introduces a variable that is unexpected at minimum and disruptive at worst.
The disruption comes in if the automation has steps to run git maintenance
run --task=<X> commands but those commands are blocked due to the
maintenance.lock file.
Functionally, these leave the default behavior as-is but allow disabling the
git maintenance start step when users opt-in to this difference. The idea of
Scalar is to recommend the best practices for a typical user, but allowing
customization for expert users.
Updates in v2
=============
* The previous use of toggle_maintenance() in register_dir() would run the
'git maintenance unregister --force' command. There is a new patch 1 that
is explicit about whether this should or should not happen and new tests
are added to verify this behavior in the later patches.
* A new patch 4 adds the --[no-]maintenance option to scalar reconfigure.
Thanks, -Stolee
Derrick Stolee (4):
scalar: customize register_dir()'s behavior
scalar register: add --no-maintenance option
scalar clone: add --no-maintenance option
scalar reconfigure: add --no-maintenance option
Documentation/scalar.adoc | 29 ++++++++++++++++++----
scalar.c | 51 +++++++++++++++++++++++++++++----------
t/t9210-scalar.sh | 20 +++++++++++++--
t/t9211-scalar-clone.sh | 11 ++++++++-
4 files changed, 90 insertions(+), 21 deletions(-)
base-commit: f65182a99e545d2f2bc22e6c1c2da192133b16a3
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1913%2Fderrickstolee%2Fscalar-no-maintenance-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1913/derrickstolee/scalar-no-maintenance-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1913
Range-diff vs v1:
-: ----------- > 1: f3a3cfe3ef1 scalar: customize register_dir()'s behavior
1: 4910bacd052 ! 2: 1b99a559520 scalar register: add --no-maintenance option
@@ Documentation/scalar.adoc: Note: when this subcommand is called in a worktree th
## scalar.c ##
-@@ scalar.c: static int stop_fsmonitor_daemon(void)
- return 0;
- }
-
--static int register_dir(void)
-+static int register_dir(int maintenance)
- {
- if (add_or_remove_enlistment(1))
- return error(_("could not add enlistment"));
-@@ scalar.c: static int register_dir(void)
- if (set_recommended_config(0))
- return error(_("could not set recommended config"));
-
-- if (toggle_maintenance(1))
-+ if (toggle_maintenance(maintenance))
- warning(_("could not turn on maintenance"));
-
- if (have_fsmonitor_support() && start_fsmonitor_daemon()) {
-@@ scalar.c: static int cmd_clone(int argc, const char **argv)
- if (res)
- goto cleanup;
-
-- res = register_dir();
-+ res = register_dir(1);
-
- cleanup:
- free(branch_to_free);
@@ scalar.c: static int cmd_list(int argc, const char **argv UNUSED)
static int cmd_register(int argc, const char **argv)
@@ scalar.c: static int cmd_register(int argc, const char **argv)
setup_enlistment_directory(argc, argv, usage, options, NULL);
-- return register_dir();
+- return register_dir(1);
++ /* If --no-maintenance, then leave maintenance as-is. */
+ return register_dir(maintenance);
}
static int get_scalar_repos(const char *key, const char *value,
-@@ scalar.c: static int cmd_run(int argc, const char **argv)
- strbuf_release(&buf);
-
- if (i == 0)
-- return register_dir();
-+ return register_dir(1);
-
- if (i > 0)
- return run_git("maintenance", "run",
- "--task", tasks[i].task, NULL);
-
-- if (register_dir())
-+ if (register_dir(1))
- return -1;
- for (i = 1; tasks[i].arg; i++)
- if (run_git("maintenance", "run",
## t/t9210-scalar.sh ##
+@@ t/t9210-scalar.sh: test_expect_success 'scalar register warns when background maintenance fails' '
+ git init register-repo &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
+ scalar register register-repo 2>err &&
+- grep "could not turn on maintenance" err
++ grep "could not toggle maintenance" err
+ '
+
+ test_expect_success 'scalar unregister' '
@@ t/t9210-scalar.sh: test_expect_success 'scalar unregister' '
scalar unregister vanish
'
+test_expect_success 'scalar register --no-maintenance' '
+ git init register-no-maint &&
++ event_log="$(pwd)/no-maint.event" &&
+ GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
++ GIT_TRACE2_EVENT="$event_log" \
++ GIT_TRACE2_EVENT_DEPTH=100 \
+ scalar register --no-maintenance register-no-maint 2>err &&
-+ test_must_be_empty err
++ test_must_be_empty err &&
++ test_subcommand ! git maintenance unregister --force <no-maint.event
+'
+
test_expect_success 'set up repository to clone' '
2: 7ab1914b830 ! 3: e52b1282d93 scalar clone: add --no-maintenance option
@@ scalar.c: static int cmd_clone(int argc, const char **argv)
goto cleanup;
- res = register_dir(1);
++ /* If --no-maintenance, then skip maintenance command entirely. */
+ res = register_dir(maintenance);
cleanup:
free(branch_to_free);
## t/t9211-scalar-clone.sh ##
-@@ t/t9211-scalar-clone.sh: test_expect_success 'scalar clone warns when background maintenance fails' '
- grep "could not turn on maintenance" err
- '
-
+@@ t/t9211-scalar-clone.sh: test_expect_success 'progress without tty' '
+ test_expect_success 'scalar clone warns when background maintenance fails' '
+ GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
+ scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
+- grep "could not turn on maintenance" err
++ grep "could not toggle maintenance" err
++'
++
+test_expect_success 'scalar clone --no-maintenance' '
+ GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
++ GIT_TRACE2_EVENT="$(pwd)/no-maint.event" \
++ GIT_TRACE2_EVENT_DEPTH=100 \
+ scalar clone --no-maintenance "file://$(pwd)/to-clone" no-maint 2>err &&
-+ ! grep "could not turn on maintenance" err
-+'
-+
++ ! grep "could not toggle maintenance" err &&
++ test_subcommand ! git maintenance unregister --force <no-maint.event
+ '
+
test_expect_success '`scalar clone --no-src`' '
- scalar clone --src "file://$(pwd)/to-clone" with-src &&
- scalar clone --no-src "file://$(pwd)/to-clone" without-src &&
-: ----------- > 4: 6fac9c4c394 scalar reconfigure: add --no-maintenance option
--
gitgitgadget
next prev parent reply other threads:[~2025-05-05 15:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 10:24 [PATCH 0/2] scalar: add --no-maintenance option Derrick Stolee via GitGitGadget
2025-04-30 10:24 ` [PATCH 1/2] scalar register: " Derrick Stolee via GitGitGadget
2025-05-02 9:15 ` Patrick Steinhardt
2025-05-02 15:01 ` Derrick Stolee
2025-04-30 10:24 ` [PATCH 2/2] scalar clone: " Derrick Stolee via GitGitGadget
2025-04-30 20:28 ` [PATCH 0/2] scalar: " Junio C Hamano
2025-05-01 13:21 ` Derrick Stolee
2025-05-01 16:38 ` Junio C Hamano
2025-05-01 18:20 ` Junio C Hamano
2025-05-05 15:27 ` Derrick Stolee via GitGitGadget [this message]
2025-05-05 15:27 ` [PATCH v2 1/4] scalar: customize register_dir()'s behavior Derrick Stolee via GitGitGadget
2025-05-05 15:27 ` [PATCH v2 2/4] scalar register: add --no-maintenance option Derrick Stolee via GitGitGadget
2025-05-05 15:27 ` [PATCH v2 3/4] scalar clone: " Derrick Stolee via GitGitGadget
2025-05-05 15:27 ` [PATCH v2 4/4] scalar reconfigure: " Derrick Stolee via GitGitGadget
2025-05-05 21:47 ` Junio C Hamano
2025-05-06 18:00 ` Derrick Stolee
2025-05-06 22:16 ` Junio C Hamano
2025-05-07 1:50 ` [PATCH v3 0/4] scalar: " Derrick Stolee via GitGitGadget
2025-05-07 1:50 ` [PATCH v3 1/4] scalar: customize register_dir()'s behavior Derrick Stolee via GitGitGadget
2025-05-07 1:50 ` [PATCH v3 2/4] scalar register: add --no-maintenance option Derrick Stolee via GitGitGadget
2025-05-07 1:50 ` [PATCH v3 3/4] scalar clone: " Derrick Stolee via GitGitGadget
2025-05-07 1:50 ` [PATCH v3 4/4] scalar reconfigure: add --maintenance=<mode> option Derrick Stolee via GitGitGadget
2025-05-07 21:46 ` Junio C Hamano
2025-05-12 14:34 ` Derrick Stolee
2025-05-12 17:44 ` Junio C Hamano
2025-05-12 18:02 ` Derrick Stolee
2025-05-14 12:28 ` Junio C Hamano
2025-05-14 13:52 ` [PATCH 5/4] scalar reconfigure: improve --maintenance docs Derrick Stolee
2025-05-14 22:16 ` Junio C Hamano
2025-05-16 16:36 ` Derrick Stolee
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1913.v2.git.1746458844.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=ps@pks.im \
--cc=stolee@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.