git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/4] scalar clone: add --no-maintenance option

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
May 5, 2025, 15:27 UTC
Message-ID
<e52b1282d93b795d077f169573487dca06b83bbe.1746458844.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1913.v2.git.1746458844.gitgitgadget@gmail.com>
From: Derrick Stolee <stolee@gmail.com>

When creating a new enlistment via 'scalar clone', the default is to set up situations that work for most user scenarios. Background maintenance is one of those highly-recommended options for most users.

However, when using 'scalar clone' to create an enlistment in a different situation, such as prepping a VM image, it may be valuable to disable background maintenance so the manual maintenance steps do not get blocked by concurrent background maintenance activities.

Add a new --no-maintenance option to 'scalar clone'.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
 Documentation/scalar.adoc |  7 ++++++-
 scalar.c                  |  9 ++++++---
 t/t9211-scalar-clone.sh   | 11 ++++++++++-
 3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/Documentation/scalar.adoc b/Documentation/scalar.adoc
index b2b244a86499..7753df3b4352 100644
--- a/Documentation/scalar.adoc
+++ b/Documentation/scalar.adoc
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]
-	[--[no-]src] <url> [<enlistment>]
+	[--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]
 scalar list
 scalar register [--[no-]maintenance] [<enlistment>]
 scalar unregister [<enlistment>]
@@ -97,6 +97,11 @@ cloning. If the HEAD at the remote did not point at any branch when
 	A sparse-checkout is initialized by default. This behavior can be
 	turned off via `--full-clone`.
 
+--[no-]maintenance::
+	By default, `scalar clone` configures the enlistment to use Git's
+	background maintenance feature. Use the `--no-maintenance` to skip
+	this configuration.
+
 List
 ~~~~
 
diff --git a/scalar.c b/scalar.c
index da0c46bc96cc..dd6e1447e086 100644
--- a/scalar.c
+++ b/scalar.c
@@ -426,7 +426,7 @@ static int cmd_clone(int argc, const char **argv)
 	const char *branch = NULL;
 	char *branch_to_free = NULL;
 	int full_clone = 0, single_branch = 0, show_progress = isatty(2);
-	int src = 1, tags = 1;
+	int src = 1, tags = 1, maintenance = 1;
 	struct option clone_options[] = {
 		OPT_STRING('b', "branch", &branch, N_("<branch>"),
 			   N_("branch to checkout after clone")),
@@ -439,11 +439,13 @@ static int cmd_clone(int argc, const char **argv)
 			 N_("create repository within 'src' directory")),
 		OPT_BOOL(0, "tags", &tags,
 			 N_("specify if tags should be fetched during clone")),
+		OPT_BOOL(0, "maintenance", &maintenance,
+			 N_("specify if background maintenance should be enabled")),
 		OPT_END(),
 	};
 	const char * const clone_usage[] = {
 		N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n"
-		   "\t[--[no-]src] [--[no-]tags] <url> [<enlistment>]"),
+		   "\t[--[no-]src] [--[no-]tags] [--[no-]maintenance] <url> [<enlistment>]"),
 		NULL
 	};
 	const char *url;
@@ -565,7 +567,8 @@ static int cmd_clone(int argc, const char **argv)
 	if (res)
 		goto cleanup;
 
-	res = register_dir(1);
+	/* If --no-maintenance, then skip maintenance command entirely. */
+	res = register_dir(maintenance);
 
 cleanup:
 	free(branch_to_free);
diff --git a/t/t9211-scalar-clone.sh b/t/t9211-scalar-clone.sh
index 01f71910f533..bfbf22a46218 100755
--- a/t/t9211-scalar-clone.sh
+++ b/t/t9211-scalar-clone.sh
@@ -177,7 +177,16 @@ 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 toggle maintenance" err &&
+	test_subcommand ! git maintenance unregister --force <no-maint.event
 '
 
 test_expect_success '`scalar clone --no-src`' '
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 13 of 30 in “scalar: add --no-maintenance option”
  1. 0/2 scalar: add --no-maintenance optionDerrick Stolee via GitGitGadget, Apr 30, 2025
  2. 1/2 scalar register: add --no-maintenance optionDerrick Stolee via GitGitGadget, Apr 30, 2025
  3. Patrick SteinhardtMay 2, 2025
  4. Derrick StoleeMay 2, 2025
  5. 2/2 scalar clone: add --no-maintenance optionDerrick Stolee via GitGitGadget, Apr 30, 2025
  6. Junio C HamanoApr 30, 2025
  7. Derrick StoleeMay 1, 2025
  8. Junio C HamanoMay 1, 2025
  9. Junio C HamanoMay 1, 2025
  10. 0/4 scalar: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 5, 2025
  11. 1/4 scalar: customize register_dir()'s behaviorDerrick Stolee via GitGitGadget, May 5, 2025
  12. 2/4 scalar register: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 5, 2025
  13. 3/4 scalar clone: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 5, 2025
  14. 4/4 scalar reconfigure: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 5, 2025
  15. Junio C HamanoMay 5, 2025
  16. Derrick StoleeMay 6, 2025
  17. Junio C HamanoMay 6, 2025
  18. 0/4 scalar: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 7, 2025
  19. 1/4 scalar: customize register_dir()'s behaviorDerrick Stolee via GitGitGadget, May 7, 2025
  20. 2/4 scalar register: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 7, 2025
  21. 3/4 scalar clone: add --no-maintenance optionDerrick Stolee via GitGitGadget, May 7, 2025
  22. 4/4 scalar reconfigure: add --maintenance=<mode> optionDerrick Stolee via GitGitGadget, May 7, 2025
  23. Junio C HamanoMay 7, 2025
  24. Derrick StoleeMay 12, 2025
  25. Junio C HamanoMay 12, 2025
  26. Derrick StoleeMay 12, 2025
  27. Junio C HamanoMay 14, 2025
  28. 5/4 scalar reconfigure: improve --maintenance docsDerrick Stolee, May 14, 2025
  29. Junio C HamanoMay 14, 2025
  30. Derrick StoleeMay 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.