Git development
 help / color / mirror / Atom feed
* [PATCH] builtin/maintenance: accept "none" as a maintenance strategy
@ 2026-07-29 19:40 David Lin
  2026-07-30  2:58 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: David Lin @ 2026-07-29 19:40 UTC (permalink / raw)
  To: git; +Cc: ps, gitster, David Lin

Commit d465be2327 (builtin/maintenance: don't silently ignore invalid
strategy, 2025-10-24) changed scheduled maintenance to error on an
unknown maintenance strategy instead of silently defaulting to the
`none` strategy.

However, `parse_maintenance_strategy()` does not recognize `none`, so
Git rejects a valid and documented strategy that can be used to override
an existing strategy and disable maintenance tasks.

Accept `none` as a valid maintenance strategy and add tests to ensure
it's accepted.

Signed-off-by: David Lin <davidlin@stripe.com>
---
 builtin/gc.c           | 2 ++
 t/t7900-maintenance.sh | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/builtin/gc.c b/builtin/gc.c
index 46999a99ab..3d1e39d46a 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1922,6 +1922,8 @@ static const struct maintenance_strategy geometric_strategy = {
 
 static struct maintenance_strategy parse_maintenance_strategy(const char *name)
 {
+	if (!strcasecmp(name, "none"))
+		return none_strategy;
 	if (!strcasecmp(name, "incremental"))
 		return incremental_strategy;
 	if (!strcasecmp(name, "gc"))
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index a8d691719d..130c971b15 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -1022,6 +1022,9 @@ test_expect_success 'maintenance.strategy is respected' '
 		test_must_fail git -c maintenance.strategy=unknown maintenance run 2>err &&
 		test_grep "unknown maintenance strategy: .unknown." err &&
 
+		test_strategy none </dev/null &&
+		test_strategy none --schedule=weekly </dev/null &&
+
 		test_strategy incremental <<-\EOF &&
 		git pack-refs --all --prune
 		git reflog expire --all

base-commit: 13c7afec212fc97ce257d15601659314c6673d6c
-- 
2.54.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] builtin/maintenance: accept "none" as a maintenance strategy
  2026-07-29 19:40 [PATCH] builtin/maintenance: accept "none" as a maintenance strategy David Lin
@ 2026-07-30  2:58 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2026-07-30  2:58 UTC (permalink / raw)
  To: David Lin; +Cc: git, ps, David Lin

David Lin <davidzylin@gmail.com> writes:

The author identity uses an @gmail.com address, but the sign-off
uses a different address.  Assuming the preferred address is the one
used in the sign-off, you can 'lie' about the author identity by
starting the body of the message with an 'in-body From:' line:

    From: David Lin <davidlin@stripe.com>

This must be written without indentation and followed by a blank line
before the true first line of the message body.

> Commit d465be2327 (builtin/maintenance: don't silently ignore invalid
> strategy, 2025-10-24) changed scheduled maintenance to error on an
> unknown maintenance strategy instead of silently defaulting to the
> `none` strategy.
>
> However, `parse_maintenance_strategy()` does not recognize `none`, so
> Git rejects a valid and documented strategy that can be used to override
> an existing strategy and disable maintenance tasks.
>
> Accept `none` as a valid maintenance strategy and add tests to ensure
> it's accepted.
>
> Signed-off-by: David Lin <davidlin@stripe.com>
> ---
>  builtin/gc.c           | 2 ++
>  t/t7900-maintenance.sh | 3 +++
>  2 files changed, 5 insertions(+)
>
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 46999a99ab..3d1e39d46a 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -1922,6 +1922,8 @@ static const struct maintenance_strategy geometric_strategy = {
>  
>  static struct maintenance_strategy parse_maintenance_strategy(const char *name)
>  {
> +	if (!strcasecmp(name, "none"))
> +		return none_strategy;
>  	if (!strcasecmp(name, "incremental"))
>  		return incremental_strategy;
>  	if (!strcasecmp(name, "gc"))
> diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
> index a8d691719d..130c971b15 100755
> --- a/t/t7900-maintenance.sh
> +++ b/t/t7900-maintenance.sh
> @@ -1022,6 +1022,9 @@ test_expect_success 'maintenance.strategy is respected' '
>  		test_must_fail git -c maintenance.strategy=unknown maintenance run 2>err &&
>  		test_grep "unknown maintenance strategy: .unknown." err &&
>  
> +		test_strategy none </dev/null &&
> +		test_strategy none --schedule=weekly </dev/null &&
> +
>  		test_strategy incremental <<-\EOF &&
>  		git pack-refs --all --prune
>  		git reflog expire --all
>
> base-commit: 13c7afec212fc97ce257d15601659314c6673d6c

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-30  2:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-29 19:40 [PATCH] builtin/maintenance: accept "none" as a maintenance strategy David Lin
2026-07-30  2:58 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox