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

Re: [PATCH 5/5] maintenance: add 'is-needed' subcommand

From
Karthik Nayak <karthik.188@gmail.com>
Date
Nov 4, 2025, 08:28 UTC
Message-ID
<CAOLa=ZRA33ro1-9jbh71QpAa3Sj-NZY5fOL_T4Shyn8jPYQi_A@mail.gmail.com>
In-Reply-To
<aQmU_hOPO55_ojw2@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 29 quoted lines
> On Mon, Nov 03, 2025 at 09:18:35AM -0800, Karthik Nayak wrote:
>> Patrick Steinhardt <ps@pks.im> writes:
>>
>> > On Fri, Oct 31, 2025 at 03:22:25PM +0100, Karthik Nayak wrote:
>> >> diff --git a/Documentation/git-maintenance.adoc b/Documentation/git-maintenance.adoc
>> >> index 540b5cf68b..edcc88f4d0 100644
>> >> --- a/Documentation/git-maintenance.adoc
>> >> +++ b/Documentation/git-maintenance.adoc
>> >> @@ -84,6 +85,11 @@ The `unregister` subcommand will report an error if the current repository
>> >>  is not already registered. Use the `--force` option to return success even
>> >>  when the current repository is not registered.
>> >>
>> >> +is-needed::
>> >> +    Check whether maintenance needs to be run without actually running it.
>> >> +    Exits with a 0 status code if maintenance needs to be run, 1 otherwise.
>> >> +    Can be used along with `--task`. Ideally should be used with '--auto'.
>> >
>> > Okay. I assume when `--task` is not given we'll check all tasks
>> > specified by the configured strategy? Might make sense to document if
>> > so.
>> >
>>
>> Actually no. It's similar to the 'run' command, if nothing is specified,
>> we check `maintenance.<task>.enabled`. By default it is only enabled for
>> 'gc'. This is important information, I will add it in.
>
> But we use `initialize_task_config()`, and that function knows to use
> the configured strategy unless it's given an explicit list of tasks. So
> we do use the maintenance strategy.
Yes, and the default strategy is to run 'gc'.

I miss-read your earlier comment, you were talking about the configured strategy. I thought you were asking if no '--task' is given, we'd run all available tasks.

Show 37 quoted lines
>
>> >> diff --git a/builtin/gc.c b/builtin/gc.c
>> >> index 72177305ff..4d20487ed6 100644
>> >> --- a/builtin/gc.c
>> >> +++ b/builtin/gc.c
> [snip]
>> >> +	} else {
>> >> +		/* When not using --auto, we should always require maintenance. */
>> >> +		is_needed = true;
>> >> +	}
>> >
>> > I guess for now this is good enough, but it's not quite true. Some tasks
>> > won't require maintenance even without `--auto`, like for example when
>> > the reftable stack only has a single table.
>> >
>> > Patrick
>>
>> Good point. Thought I'm not sure how we'd go about it. Initially I
>> wanted to not have an `--auto` flag and simply make it the default
>> behavior. But that would restrict us from introducing the `schedule`
>> flag in the future. Which I think might be a worthwhile addition.
>
> Yeah, agreed.
>
> I guess eventually we could extend `auto_condition()` to honor the
> "--auto" flag:
>
>   - If it's set the task verifies that it needs to trigger housekeeping
>     tasks with heuristics.
>
>   - Otherwise it checks whether there even is anything that could be
>     cleaned up.
>
> But that's certainly out of scope of this patch series, I think it's
> good enough to bail on that specific part for now.
>
> Patrick
I think that's a fair conclusion. I'll leave this as is for now then.
Thanks for the review.
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 22 of 57 in “maintenance: add an 'is-needed' subcommand”
  1. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Oct 31, 2025
  2. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Oct 31, 2025
  3. Justin ToblerOct 31, 2025
  4. Karthik NayakNov 3, 2025
  5. Justin ToblerNov 3, 2025
  6. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Oct 31, 2025
  7. Justin ToblerOct 31, 2025
  8. Junio C HamanoOct 31, 2025
  9. Karthik NayakNov 3, 2025
  10. Karthik NayakNov 3, 2025
  11. Justin ToblerNov 3, 2025
  12. Patrick SteinhardtNov 3, 2025
  13. Karthik NayakNov 3, 2025
  14. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Oct 31, 2025
  15. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Oct 31, 2025
  16. Patrick SteinhardtNov 3, 2025
  17. Karthik NayakNov 3, 2025
  18. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Oct 31, 2025
  19. Patrick SteinhardtNov 3, 2025
  20. Karthik NayakNov 3, 2025
  21. Patrick SteinhardtNov 4, 2025
  22. Karthik NayakNov 4, 2025
  23. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Nov 4, 2025
  24. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Nov 4, 2025
  25. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Nov 4, 2025
  26. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Nov 4, 2025
  27. Junio C HamanoNov 4, 2025
  28. Karthik NayakNov 5, 2025
  29. Junio C HamanoNov 5, 2025
  30. Karthik NayakNov 6, 2025
  31. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Nov 4, 2025
  32. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Nov 4, 2025
  33. Junio C HamanoNov 4, 2025
  34. Karthik NayakNov 5, 2025
  35. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Nov 6, 2025
  36. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Nov 6, 2025
  37. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Nov 6, 2025
  38. Junio C HamanoNov 6, 2025
  39. Patrick SteinhardtNov 7, 2025
  40. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Nov 6, 2025
  41. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Nov 6, 2025
  42. Patrick SteinhardtNov 6, 2025
  43. Karthik NayakNov 6, 2025
  44. Junio C HamanoNov 6, 2025
  45. Karthik NayakNov 7, 2025
  46. Junio C HamanoNov 7, 2025
  47. Karthik NayakNov 7, 2025
  48. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Nov 6, 2025
  49. Patrick SteinhardtNov 6, 2025
  50. Karthik NayakNov 6, 2025
  51. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Nov 8, 2025
  52. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Nov 8, 2025
  53. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Nov 8, 2025
  54. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Nov 8, 2025
  55. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Nov 8, 2025
  56. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Nov 8, 2025
  57. Patrick SteinhardtNov 10, 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.