{"thread":{"id":"66269","subject":"[PATCH 0/2] sequencer: leave auto maintenance to the end of a rebase","startedAt":"2026-09-04T07:53:48Z","lastAt":"2026-09-28T07:49:15Z","messageCount":52,"participants":["Thomas Bachem via GitGitGadget","Phillip Wood","Thomas Bachem","Junio C Hamano","Patrick Steinhardt","Kristoffer Haugsbakk"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"551933","messageId":"pull.2217.git.1788508426.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":null,"subject":"[PATCH 0/2] sequencer: leave auto maintenance to the end of a rebase","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T07:53:44Z","receivedAt":"2026-09-04T07:53:48Z","isPatch":true,"body":"While looking into the rerere lock race in [1], the \"git commit\" a rebase\nspawns for a resolved pick turned out to be about the only place a rebase\nwith the merge backend runs auto maintenance, and it runs it against the\nrebase itself. Phillip asked for auto maintenance to be kept out of a rebase\naltogether [2], and for the merge backend to run it once at the end the way\nthe apply backend does [3]. Patrick would rather see that discussed on its\nown [4], hence this series.\n\nPatch 1 runs auto maintenance where the sequencer finishes a rebase, as the\napply backend does. Patch 2 then passes maintenance.auto=false and gc.auto=0\nto the \"git commit\", \"git merge\" and exec commands a rebase spawns, so that\na rebase runs it once, at its end. Cherry-pick and revert are left as they\nare.\n\nBased on master. Independent of [1], which makes the rerere lock non-fatal:\nwith both, a rebase neither spawns the gc nor dies on one that something\nelse spawned.\n\n[1] <pull.2214.git.1788337897490.gitgitgadget@gmail.com>\n\n[2] <ca3b91b6-254c-4b86-adb8-da3217e9f6e7@gmail.com>\n\n[3] <86efb07c-a0ce-49b0-b4eb-7d6b4bbaeccc@gmail.com>\n\n[4] <apkwpKTGaMwTf0Hz@pks.im>\n\nThomas Bachem (2):\n  sequencer: run auto maintenance once a rebase is done\n  sequencer: keep auto maintenance out of the commands a rebase spawns\n\n sequencer.c                | 32 ++++++++++++++++++++++++++++++++\n t/t3418-rebase-continue.sh | 26 ++++++++++++++++++++++++++\n 2 files changed, 58 insertions(+)\n\n\nbase-commit: 3cb9185f65410273787f74333cc027d2ea5daada\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2217\n-- \ngitgitgadget\n"},{"id":"551934","messageId":"3415a4dcbf3c83f85aed3d806d897f5f4906715d.1788508426.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.git.1788508426.gitgitgadget@gmail.com","subject":"[PATCH 1/2] sequencer: run auto maintenance once a rebase is done","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T07:53:45Z","receivedAt":"2026-09-04T07:53:49Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nThe apply backend runs \"git maintenance run --auto\" from\nfinish_rebase() once it has applied its patches, and so does \"git am\"\non its own. The merge backend reaches finish_rebase() only on the\npaths both backends share in builtin/rebase.c: an abort, a branch\nthat is already up to date, and a fast-forward. A rebase that\nreplays commits never runs maintenance at its end. It creates most\nof its commits in process, and only the \"git commit\" it spawns for a\nresolved, reworded or squashed pick, the \"git merge\" a \"rebase -r\"\nspawns for an octopus merge or with a strategy, and whatever an exec\ncommand runs kick maintenance off, in the middle of the rebase. Run\nit where the sequencer finishes a rebase, after the autostash is\napplied, as finish_rebase() does, so that both backends end a rebase\nthe same way, and so that the next commit can keep it out of the\ncommands a rebase spawns. builtin/rebase.c could run it instead once\nrun_sequencer_rebase() returns, but the sequencer is where the rebase\nfinishes, and the autostash and the state cleanup that surround the\nrun in finish_rebase() are there as well. prepare_auto_maintenance()\ncloses the object database before the spawn, so the sequencer holds\nnothing a repack would need to replace.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                | 5 +++++\n t/t3418-rebase-continue.sh | 8 ++++++++\n 2 files changed, 13 insertions(+)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 65afd100d9..f58ad254be 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5297,6 +5297,11 @@ cleanup_head_ref:\n \t\t\trun_hooks_opt(r, \"post-rewrite\", &hook_opt);\n \t\t}\n \t\tapply_autostash(rebase_path_autostash());\n+\t\t/*\n+\t\t * We ignore errors in 'git maintenance run --auto', since the\n+\t\t * user should see them.\n+\t\t */\n+\t\trun_auto_maintenance(r, opts->quiet);\n \n \t\tif (!opts->quiet) {\n \t\t\tif (!opts->verbose)\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex cb5c3a1cb5..2c34cf8a01 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -395,4 +395,12 @@ test_orig_head () {\n test_orig_head --apply\n test_orig_head --merge\n \n+test_expect_success 'rebase runs auto maintenance at its end' '\n+\tgit checkout -b one-exec main^ &&\n+\ttest_commit F4 &&\n+\ttest_must_fail git rebase -x false main &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/finish.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <finish.txt\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"551935","messageId":"06d2f0f484e2e22178c6a956ec153e3d84ee073c.1788508426.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.git.1788508426.gitgitgadget@gmail.com","subject":"[PATCH 2/2] sequencer: keep auto maintenance out of the commands a rebase spawns","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T07:53:46Z","receivedAt":"2026-09-04T07:53:50Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nThe commands a rebase with the merge backend spawns, the \"git commit\"\nfor a resolved, reworded or squashed pick, the \"git merge\" of a\n\"rebase -r\" for an octopus merge or with a strategy, and whatever an\nexec command runs, each kick off \"git maintenance run --auto --detach\",\na background process the rebase then races for the repository: the\n\"rerere gc\" spawned by the commit of one \"git rebase --continue\" holds\nMERGE_RR.lock while the next pick wants it, and a repack wants to\ndelete packs the sequencer still had open, which 65cda10d5b\n(sequencer: release the ODB before spawning git commit, 2026-08-12)\nhad to fix for Windows.\n\nNothing a rebase creates is old enough to be pruned by the time it\nends, and repacking what it created can wait until then, so\nmaintenance in the middle of a rebase has nothing to do that a run at\nits end cannot, and a rebase to get in the way of. Pass\nmaintenance.auto=false and gc.auto=0 to the commands a rebase spawns,\nthrough GIT_CONFIG_PARAMETERS so that the shell of an exec command\npasses them on too, appended to whatever -c the user gave, since the\nlast entry wins. What the user runs while the rebase is stopped, say\n\"git commit --amend\" at an edit, is not the rebase's to control and\nstill runs it. \"git commit\" and \"git merge\" could skip it themselves\nwhile a rebase is in progress, which would cover that too, but that\nspreads the rebase's business over every command that runs\nmaintenance and defers theirs for as long as a rebase is left lying\naround, so keep the decision with the rebase, in what it spawns. Both\nbackends run maintenance once the rebase is done, the merge backend\nsince the previous commit, so nothing is lost.\n\nCherry-pick and revert are left alone: they never ran maintenance at\nthe end of a sequence, and the \"git commit\" they spawn for a\n--continue or an edited message is the only place they run it at all.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                | 27 +++++++++++++++++++++++++++\n t/t3418-rebase-continue.sh | 18 ++++++++++++++++++\n 2 files changed, 45 insertions(+)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex f58ad254be..30c1a799cc 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1107,6 +1107,29 @@ static int run_command_silent_on_success(struct child_process *cmd)\n \treturn rc;\n }\n \n+/*\n+ * A rebase runs auto maintenance once it is done, not from every command\n+ * it spawns along the way: their background \"rerere gc\" or repack would\n+ * race the rebase for locks and files it still holds.\n+ */\n+static void disable_auto_maintenance(struct child_process *cmd)\n+{\n+\tstruct strbuf value = STRBUF_INIT;\n+\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n+\n+\tif (old && *old)\n+\t\tstrbuf_addf(&value, \"%s \", old);\n+\tsq_quote_buf(&value, \"maintenance.auto\");\n+\tstrbuf_addch(&value, '=');\n+\tsq_quote_buf(&value, \"false\");\n+\tstrbuf_addch(&value, ' ');\n+\tsq_quote_buf(&value, \"gc.auto\");\n+\tstrbuf_addch(&value, '=');\n+\tsq_quote_buf(&value, \"0\");\n+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, value.buf);\n+\tstrbuf_release(&value);\n+}\n+\n /*\n  * If we are cherry-pick, and if the merge did not result in\n  * hand-editing, we will hit this commit and inherit the original\n@@ -1148,6 +1171,8 @@ static int run_git_commit(const char *defmsg,\n \t\t\t     author_date_from_env(&cmd.env));\n \tif (opts->ignore_date)\n \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\tif (is_rebase_i(opts))\n+\t\tdisable_auto_maintenance(&cmd);\n \n \tstrvec_push(&cmd.args, \"commit\");\n \n@@ -3934,6 +3959,7 @@ static int do_exec(struct repository *r, const char *command_line, int quiet)\n \tcmd.use_shell = 1;\n \tstrvec_push(&cmd.args, command_line);\n \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n+\tdisable_auto_maintenance(&cmd);\n \tstatus = run_command(&cmd);\n \n \t/* force re-reading of the cache */\n@@ -4342,6 +4368,7 @@ static int do_merge(struct repository *r,\n \t\t\t\t     author_date_from_env(&cmd.env));\n \t\tif (opts->ignore_date)\n \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\t\tdisable_auto_maintenance(&cmd);\n \n \t\tcmd.git_cmd = 1;\n \t\tstrvec_push(&cmd.args, \"merge\");\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 2c34cf8a01..cf6d20ce79 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' '\n \ttest_subcommand_flex git maintenance run --auto <finish.txt\n '\n \n+test_expect_success 'rebase spawns no auto maintenance before its end' '\n+\tgit checkout -b two-conflicts topic &&\n+\ttest_commit F2-again F2 222 &&\n+\ttest_must_fail git rebase -x \"git commit --allow-empty -m exec\" main &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit rebase --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n test_done\n-- \ngitgitgadget\n"},{"id":"551968","messageId":"f44765f2-d04f-4adc-b5f0-56a22658626b@gmail.com","threadId":"66269","inReplyTo":"06d2f0f484e2e22178c6a956ec153e3d84ee073c.1788508426.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 2/2] sequencer: keep auto maintenance out of the commands a rebase spawns","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-04T15:03:09Z","receivedAt":"2026-09-04T15:03:14Z","isPatch":true,"body":"Hi Thomas\n\nOn 04/09/2026 08:53, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> The commands a rebase with the merge backend spawns, the \"git commit\"\n> for a resolved, reworded or squashed pick, the \"git merge\" of a\n> \"rebase -r\" for an octopus merge or with a strategy, and whatever an\n> exec command runs, each kick off \"git maintenance run --auto --detach\",\n> a background process the rebase then races for the repository: the\n> \"rerere gc\" spawned by the commit of one \"git rebase --continue\" holds\n> MERGE_RR.lock while the next pick wants it, and a repack wants to\n> delete packs the sequencer still had open, which 65cda10d5b\n> (sequencer: release the ODB before spawning git commit, 2026-08-12)\n> had to fix for Windows.\n\nThis entire paragraph is a single sentence and is very hard to understand.\n> Nothing a rebase creates is old enough to be pruned by the time it\n\ns/Nothing/The objects/?\n\n> ends, and repacking what it created can wait until then,\n\nThat's what we'll find out when this is merged. In principle it is \npossible someone is doing enormous rebases where the number of loose \nobjects impacts the performance if we don't repack mid-rebase but I \ndon't think we can know that without disabling auto maintenance and \nseeing if anyone complians.\n\n> so\n> maintenance in the middle of a rebase has nothing to do that a run at\n> its end cannot, and a rebase to get in the way of.\n\nThat last clause is hard to parse.\n\n> Pass\n> maintenance.auto=false and gc.auto=0 to the commands a rebase spawns,\n> through GIT_CONFIG_PARAMETERS so that the shell of an exec command\n> passes them on too, appended to whatever -c the user gave, since the\n> last entry wins. What the user runs while the rebase is stopped, say\n> \"git commit --amend\" at an edit, is not the rebase's to control and\n> still runs it. \n\ns/runs/run/\n\n> \"git commit\" and \"git merge\" could skip it themselves\n> while a rebase is in progress, which would cover that too, but that\n> spreads the rebase's business over every command that runs\n> maintenance and defers theirs for as long as a rebase is left lying\n> around, so keep the decision with the rebase, in what it spawns. Both\n> backends run maintenance once the rebase is done, the merge backend\n> since the previous commit, so nothing is lost.\n> \n> Cherry-pick and revert are left alone: they never ran maintenance at\n> the end of a sequence, and the \"git commit\" they spawn for a\n> --continue or an edited message is the only place they run it at all.\n\nI'm inclined to think that the reasoning for running maintenance at the \nend of a rebase applies to cherry-pick and probably revert as well.\n\n> \n> Assisted-by: Claude Fable 5.1\n> Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n> ---\n>   sequencer.c                | 27 +++++++++++++++++++++++++++\n>   t/t3418-rebase-continue.sh | 18 ++++++++++++++++++\n>   2 files changed, 45 insertions(+)\n> \n> diff --git a/sequencer.c b/sequencer.c\n> index f58ad254be..30c1a799cc 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -1107,6 +1107,29 @@ static int run_command_silent_on_success(struct child_process *cmd)\n>   \treturn rc;\n>   }\n>   \n> +/*\n> + * A rebase runs auto maintenance once it is done, not from every command\n> + * it spawns along the way: their background \"rerere gc\" or repack would\n> + * race the rebase for locks and files it still holds.\n> + */\n> +static void disable_auto_maintenance(struct child_process *cmd)\n> +{\n> +\tstruct strbuf value = STRBUF_INIT;\n> +\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n> +\n> +\tif (old && *old)\n> +\t\tstrbuf_addf(&value, \"%s \", old);\n> +\tsq_quote_buf(&value, \"maintenance.auto\");\n> +\tstrbuf_addch(&value, '=');\n> +\tsq_quote_buf(&value, \"false\");\n> +\tstrbuf_addch(&value, ' ');\n> +\tsq_quote_buf(&value, \"gc.auto\");\n> +\tstrbuf_addch(&value, '=');\n> +\tsq_quote_buf(&value, \"0\");\n> +\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, value.buf);\n> +\tstrbuf_release(&value);\n> +}\n\nWe already have a function in config.c to append parameters, but it sets \nthem in the callers environment which we don't want to do here. I wonder \nif we could factor out a helper append the parameters to an strbuf \npassed by the caller so we don't need to know about the quoting scheme \nhere. Also it would be nice to cache this in replay_ctx so we don't have \nto construct the string each time we want to disable auto maintenance.\n\nOther than that this looks good\n\nThanks\n\nPhillip\n\n\n> +\n>   /*\n>    * If we are cherry-pick, and if the merge did not result in\n>    * hand-editing, we will hit this commit and inherit the original\n> @@ -1148,6 +1171,8 @@ static int run_git_commit(const char *defmsg,\n>   \t\t\t     author_date_from_env(&cmd.env));\n>   \tif (opts->ignore_date)\n>   \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n> +\tif (is_rebase_i(opts))\n> +\t\tdisable_auto_maintenance(&cmd);\n>   \n>   \tstrvec_push(&cmd.args, \"commit\");\n>   \n> @@ -3934,6 +3959,7 @@ static int do_exec(struct repository *r, const char *command_line, int quiet)\n>   \tcmd.use_shell = 1;\n>   \tstrvec_push(&cmd.args, command_line);\n>   \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n> +\tdisable_auto_maintenance(&cmd);\n>   \tstatus = run_command(&cmd);\n>   \n>   \t/* force re-reading of the cache */\n> @@ -4342,6 +4368,7 @@ static int do_merge(struct repository *r,\n>   \t\t\t\t     author_date_from_env(&cmd.env));\n>   \t\tif (opts->ignore_date)\n>   \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n> +\t\tdisable_auto_maintenance(&cmd);\n>   \n>   \t\tcmd.git_cmd = 1;\n>   \t\tstrvec_push(&cmd.args, \"merge\");\n> diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\n> index 2c34cf8a01..cf6d20ce79 100755\n> --- a/t/t3418-rebase-continue.sh\n> +++ b/t/t3418-rebase-continue.sh\n> @@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' '\n>   \ttest_subcommand_flex git maintenance run --auto <finish.txt\n>   '\n>   \n> +test_expect_success 'rebase spawns no auto maintenance before its end' '\n> +\tgit checkout -b two-conflicts topic &&\n> +\ttest_commit F2-again F2 222 &&\n> +\ttest_must_fail git rebase -x \"git commit --allow-empty -m exec\" main &&\n> +\techo resolved >F2 &&\n> +\tgit add F2 &&\n> +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n> +\t\tgit rebase --continue &&\n> +\ttest_subcommand_flex git commit <mid.txt &&\n> +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n> +\techo resolved >F2 &&\n> +\tgit add F2 &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n> +\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n> +\ttest_line_count = 1 maintenance\n> +'\n> +\n>   test_done\n\n"},{"id":"551969","messageId":"845f8476-3105-4174-af51-9dd74147ea33@gmail.com","threadId":"66269","inReplyTo":"3415a4dcbf3c83f85aed3d806d897f5f4906715d.1788508426.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/2] sequencer: run auto maintenance once a rebase is done","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-04T15:03:28Z","receivedAt":"2026-09-04T15:03:32Z","isPatch":true,"body":"Hi Thomas\n\nOn 04/09/2026 08:53, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> The apply backend runs \"git maintenance run --auto\" from\n> finish_rebase() once it has applied its patches, and so does \"git am\"\n> on its own. The merge backend reaches finish_rebase() only on the\n> paths both backends share in builtin/rebase.c: an abort, a branch\n> that is already up to date, and a fast-forward. A rebase that\n> replays commits never runs maintenance at its end. It creates most\n> of its commits in process, and only the \"git commit\" it spawns for a\n> resolved, reworded or squashed pick, the \"git merge\" a \"rebase -r\"\n> spawns for an octopus merge or with a strategy, and whatever an exec\n> command runs kick maintenance off, in the middle of the rebase. Run\n> it where the sequencer finishes a rebase, after the autostash is\n> applied, as finish_rebase() does, so that both backends end a rebase\n> the same way, and so that the next commit can keep it out of the\n> commands a rebase spawns. builtin/rebase.c could run it instead once\n> run_sequencer_rebase() returns, but the sequencer is where the rebase\n> finishes, and the autostash and the state cleanup that surround the\n> run in finish_rebase() are there as well. prepare_auto_maintenance()\n> closes the object database before the spawn, so the sequencer holds\n> nothing a repack would need to replace.\n\nIt would be nice if the two backends shared more of the cleanup code, I \ndon't think there is a good reason for them not to share the code that \ncopies notes, applies the autostash and switches HEAD back to the \nbranch, but that is outside the scope of this change. So adding a \nseparate call to the sequencer code seems reasonable. I wonder if we \nshould do this for cherry-pick and revert as well; certainly cherry-pick \ncan create a lot of loose objects and does not necessarily call \"git \ncommit\". If cherry-pick does call \"git commit\" and trigger background \nmaintenance it is susceptible to the same problems as rebase, so we \nshould probably treat them the same.\n\nThanks\n\nPhillip\n\n> \n> Assisted-by: Claude Fable 5.1\n> Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n> ---\n>   sequencer.c                | 5 +++++\n>   t/t3418-rebase-continue.sh | 8 ++++++++\n>   2 files changed, 13 insertions(+)\n> \n> diff --git a/sequencer.c b/sequencer.c\n> index 65afd100d9..f58ad254be 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -5297,6 +5297,11 @@ cleanup_head_ref:\n>   \t\t\trun_hooks_opt(r, \"post-rewrite\", &hook_opt);\n>   \t\t}\n>   \t\tapply_autostash(rebase_path_autostash());\n> +\t\t/*\n> +\t\t * We ignore errors in 'git maintenance run --auto', since the\n> +\t\t * user should see them.\n> +\t\t */\n> +\t\trun_auto_maintenance(r, opts->quiet);\n>   \n>   \t\tif (!opts->quiet) {\n>   \t\t\tif (!opts->verbose)\n> diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\n> index cb5c3a1cb5..2c34cf8a01 100755\n> --- a/t/t3418-rebase-continue.sh\n> +++ b/t/t3418-rebase-continue.sh\n> @@ -395,4 +395,12 @@ test_orig_head () {\n>   test_orig_head --apply\n>   test_orig_head --merge\n>   \n> +test_expect_success 'rebase runs auto maintenance at its end' '\n> +\tgit checkout -b one-exec main^ &&\n> +\ttest_commit F4 &&\n> +\ttest_must_fail git rebase -x false main &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/finish.txt\" git rebase --continue &&\n> +\ttest_subcommand_flex git maintenance run --auto <finish.txt\n> +'\n> +\n>   test_done\n\n"},{"id":"551975","messageId":"pull.2217.v2.git.1788537086.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.git.1788508426.gitgitgadget@gmail.com","subject":"[PATCH v2 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T15:51:23Z","receivedAt":"2026-09-04T15:51:28Z","isPatch":true,"body":"Changes since v1:\n\n * Cherry-pick and revert end their sequences with auto maintenance too, and\n   keep it out of the \"git commit\" they spawn, so the three commands now\n   behave the same (Phillip).\n * The GIT_CONFIG_PARAMETERS value comes from a helper split out of\n   git_config_push_split_parameter() in config.c (new patch 1), built once\n   per run and kept in replay_ctx (Phillip).\n * Commit messages rewritten, much shorter (Junio, Phillip).\n\nBased on master. Independent of the rerere lock fix in [1].\n\n[1] <pull.2214.v2.git.1788507876543.gitgitgadget@gmail.com>\n\nThomas Bachem (3):\n  config: add git_config_append_parameter()\n  sequencer: run auto maintenance once a sequence is done\n  sequencer: keep auto maintenance out of the commands a sequence spawns\n\n config.c                        | 20 ++++++++----\n config.h                        | 10 ++++++\n sequencer.c                     | 57 +++++++++++++++++++++++++++++----\n t/t3418-rebase-continue.sh      | 26 +++++++++++++++\n t/t3510-cherry-pick-sequence.sh | 27 ++++++++++++++++\n 5 files changed, 127 insertions(+), 13 deletions(-)\n\n\nbase-commit: 3cb9185f65410273787f74333cc027d2ea5daada\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2217\n\nRange-diff vs v1:\n\n -:  ---------- > 1:  ef8087e80d config: add git_config_append_parameter()\n 1:  3415a4dcbf ! 2:  baab8d4876 sequencer: run auto maintenance once a rebase is done\n     @@ Metadata\n      Author: Thomas Bachem <mail@thomasbachem.com>\n      \n       ## Commit message ##\n     -    sequencer: run auto maintenance once a rebase is done\n     +    sequencer: run auto maintenance once a sequence is done\n      \n     -    The apply backend runs \"git maintenance run --auto\" from\n     -    finish_rebase() once it has applied its patches, and so does \"git am\"\n     -    on its own. The merge backend reaches finish_rebase() only on the\n     -    paths both backends share in builtin/rebase.c: an abort, a branch\n     -    that is already up to date, and a fast-forward. A rebase that\n     -    replays commits never runs maintenance at its end. It creates most\n     -    of its commits in process, and only the \"git commit\" it spawns for a\n     -    resolved, reworded or squashed pick, the \"git merge\" a \"rebase -r\"\n     -    spawns for an octopus merge or with a strategy, and whatever an exec\n     -    command runs kick maintenance off, in the middle of the rebase. Run\n     -    it where the sequencer finishes a rebase, after the autostash is\n     -    applied, as finish_rebase() does, so that both backends end a rebase\n     -    the same way, and so that the next commit can keep it out of the\n     -    commands a rebase spawns. builtin/rebase.c could run it instead once\n     -    run_sequencer_rebase() returns, but the sequencer is where the rebase\n     -    finishes, and the autostash and the state cleanup that surround the\n     -    run in finish_rebase() are there as well. prepare_auto_maintenance()\n     -    closes the object database before the spawn, so the sequencer holds\n     -    nothing a repack would need to replace.\n     +    The apply backend of \"git rebase\" runs \"git maintenance run --auto\"\n     +    from finish_rebase() once it has applied its patches. The merge\n     +    backend, \"git cherry-pick\" and \"git revert\" do not run it when they\n     +    finish. They create their commits in process, and only the \"git\n     +    commit\" they spawn for an edited message or a resolved conflict, the\n     +    \"git merge\" a \"rebase -r\" spawns and an exec command start it, in the\n     +    middle of the sequence.\n     +\n     +    Run it where the sequencer finishes, so that every sequence ends the\n     +    way the apply backend does, and so that the next commit can keep it\n     +    out of the commands a sequence spawns.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n      \n       ## sequencer.c ##\n      @@ sequencer.c: cleanup_head_ref:\n     - \t\t\trun_hooks_opt(r, \"post-rewrite\", &hook_opt);\n     + \t\t\treturn -1;\n     + \t}\n     + \n     ++\t/*\n     ++\t * We ignore errors in 'git maintenance run --auto', since the\n     ++\t * user should see them.\n     ++\t */\n     ++\trun_auto_maintenance(r, opts->quiet);\n     ++\n     + \t/*\n     + \t * Sequence of picks finished successfully; cleanup by\n     + \t * removing the .git/sequencer directory\n     +@@ sequencer.c: int sequencer_continue(struct repository *r, struct replay_opts *opts)\n     + \t\t\tres = -1;\n     + \t\t\tgoto release_todo_list;\n       \t\t}\n     - \t\tapply_autostash(rebase_path_autostash());\n     -+\t\t/*\n     -+\t\t * We ignore errors in 'git maintenance run --auto', since the\n     -+\t\t * user should see them.\n     -+\t\t */\n     -+\t\trun_auto_maintenance(r, opts->quiet);\n     +-\t} else if (!file_exists(get_todo_path(opts)))\n     +-\t\treturn continue_single_pick(r, opts);\n     +-\telse if ((res = read_populate_todo(r, &todo_list, opts)))\n     ++\t} else if (!file_exists(get_todo_path(opts))) {\n     ++\t\tres = continue_single_pick(r, opts);\n     ++\t\tif (!res)\n     ++\t\t\trun_auto_maintenance(r, opts->quiet);\n     ++\t\treturn res;\n     ++\t} else if ((res = read_populate_todo(r, &todo_list, opts))) {\n     + \t\tgoto release_todo_list;\n     ++\t}\n     + \n     + \tif (!is_rebase_i(opts)) {\n     + \t\t/* Verify that the conflict has been resolved */\n     +@@ sequencer.c: int sequencer_pick_revisions(struct repository *r,\n     + \t\t\tBUG(\"unexpected extra commit from walk\");\n     + \n     + \t\tres = single_pick(r, cmit, opts);\n     ++\t\tif (!res)\n     ++\t\t\trun_auto_maintenance(r, opts->quiet);\n     + \t\tgoto out;\n     + \t}\n       \n     - \t\tif (!opts->quiet) {\n     - \t\t\tif (!opts->verbose)\n      \n       ## t/t3418-rebase-continue.sh ##\n      @@ t/t3418-rebase-continue.sh: test_orig_head () {\n     @@ t/t3418-rebase-continue.sh: test_orig_head () {\n      +'\n      +\n       test_done\n     +\n     + ## t/t3510-cherry-pick-sequence.sh ##\n     +@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in insn sheet are optional' '\n     + \ttest_line_count = 4 commits\n     + '\n     + \n     ++test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n     ++\tpristine_detach base &&\n     ++\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n     ++\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n     ++\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n     ++\t\tgit cherry-pick anotherpick yetanotherpick &&\n     ++\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n     ++\ttest_line_count = 1 maintenance\n     ++'\n     ++\n     + test_done\n 2:  06d2f0f484 ! 3:  9a6fc0427a sequencer: keep auto maintenance out of the commands a rebase spawns\n     @@ Metadata\n      Author: Thomas Bachem <mail@thomasbachem.com>\n      \n       ## Commit message ##\n     -    sequencer: keep auto maintenance out of the commands a rebase spawns\n     +    sequencer: keep auto maintenance out of the commands a sequence spawns\n      \n     -    The commands a rebase with the merge backend spawns, the \"git commit\"\n     -    for a resolved, reworded or squashed pick, the \"git merge\" of a\n     -    \"rebase -r\" for an octopus merge or with a strategy, and whatever an\n     -    exec command runs, each kick off \"git maintenance run --auto --detach\",\n     -    a background process the rebase then races for the repository: the\n     -    \"rerere gc\" spawned by the commit of one \"git rebase --continue\" holds\n     -    MERGE_RR.lock while the next pick wants it, and a repack wants to\n     -    delete packs the sequencer still had open, which 65cda10d5b\n     +    The \"git commit\" and \"git merge\" the sequencer spawns, and the git\n     +    commands an exec runs, each start \"git maintenance run --auto\n     +    --detach\", which then works in the background against the sequence\n     +    itself. A \"rerere gc\" started by the commit of one \"git rebase\n     +    --continue\" holds MERGE_RR.lock when the next pick needs it, and a\n     +    repack deletes packs the sequencer still has open, which 65cda10d5b\n          (sequencer: release the ODB before spawning git commit, 2026-08-12)\n     -    had to fix for Windows.\n     +    had to work around.\n      \n     -    Nothing a rebase creates is old enough to be pruned by the time it\n     -    ends, and repacking what it created can wait until then, so\n     -    maintenance in the middle of a rebase has nothing to do that a run at\n     -    its end cannot, and a rebase to get in the way of. Pass\n     -    maintenance.auto=false and gc.auto=0 to the commands a rebase spawns,\n     -    through GIT_CONFIG_PARAMETERS so that the shell of an exec command\n     -    passes them on too, appended to whatever -c the user gave, since the\n     -    last entry wins. What the user runs while the rebase is stopped, say\n     -    \"git commit --amend\" at an edit, is not the rebase's to control and\n     -    still runs it. \"git commit\" and \"git merge\" could skip it themselves\n     -    while a rebase is in progress, which would cover that too, but that\n     -    spreads the rebase's business over every command that runs\n     -    maintenance and defers theirs for as long as a rebase is left lying\n     -    around, so keep the decision with the rebase, in what it spawns. Both\n     -    backends run maintenance once the rebase is done, the merge backend\n     -    since the previous commit, so nothing is lost.\n     -\n     -    Cherry-pick and revert are left alone: they never ran maintenance at\n     -    the end of a sequence, and the \"git commit\" they spawn for a\n     -    --continue or an edited message is the only place they run it at all.\n     +    The loose objects a sequence creates wait for the run at its end that\n     +    the previous commit added. Whether a sequence can be long enough to\n     +    suffer from them before that remains to be seen. Pass\n     +    maintenance.auto=false and gc.auto=0 to the spawned commands through\n     +    GIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to\n     +    whatever it runs, appended after the user's own -c settings so that\n     +    ours win, and built once per run. A command the user runs while the\n     +    sequence is stopped, like \"git commit --amend\" at an edit, is not the\n     +    sequencer's to control and still runs maintenance.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n      \n       ## sequencer.c ##\n     +@@ sequencer.c: struct replay_ctx {\n     + \t * Whether message contains a commit message.\n     + \t */\n     + \tunsigned have_message :1;\n     ++\t/*\n     ++\t * The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out\n     ++\t * of the commands we spawn, built on first use.\n     ++\t */\n     ++\tstruct strbuf config_parameters;\n     + };\n     + \n     + struct replay_ctx* replay_ctx_new(void)\n     +@@ sequencer.c: struct replay_ctx* replay_ctx_new(void)\n     + \n     + \tstrbuf_init(&ctx->current_fixups, 0);\n     + \tstrbuf_init(&ctx->message, 0);\n     ++\tstrbuf_init(&ctx->config_parameters, 0);\n     + \n     + \treturn ctx;\n     + }\n     +@@ sequencer.c: static void replay_ctx_release(struct replay_ctx *ctx)\n     + {\n     + \tstrbuf_release(&ctx->current_fixups);\n     + \tstrbuf_release(&ctx->message);\n     ++\tstrbuf_release(&ctx->config_parameters);\n     + }\n     + \n     + void replay_opts_release(struct replay_opts *opts)\n      @@ sequencer.c: static int run_command_silent_on_success(struct child_process *cmd)\n       \treturn rc;\n       }\n       \n      +/*\n     -+ * A rebase runs auto maintenance once it is done, not from every command\n     ++ * A sequence runs auto maintenance once it is done, not from every command\n      + * it spawns along the way: their background \"rerere gc\" or repack would\n     -+ * race the rebase for locks and files it still holds.\n     ++ * race the sequencer for locks and files it still holds.\n      + */\n     -+static void disable_auto_maintenance(struct child_process *cmd)\n     ++static void disable_auto_maintenance(struct replay_opts *opts,\n     ++\t\t\t\t     struct child_process *cmd)\n      +{\n     -+\tstruct strbuf value = STRBUF_INIT;\n     -+\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n     ++\tstruct strbuf *params = &opts->ctx->config_parameters;\n      +\n     -+\tif (old && *old)\n     -+\t\tstrbuf_addf(&value, \"%s \", old);\n     -+\tsq_quote_buf(&value, \"maintenance.auto\");\n     -+\tstrbuf_addch(&value, '=');\n     -+\tsq_quote_buf(&value, \"false\");\n     -+\tstrbuf_addch(&value, ' ');\n     -+\tsq_quote_buf(&value, \"gc.auto\");\n     -+\tstrbuf_addch(&value, '=');\n     -+\tsq_quote_buf(&value, \"0\");\n     -+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, value.buf);\n     -+\tstrbuf_release(&value);\n     ++\tif (!params->len) {\n     ++\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n     ++\n     ++\t\tif (old && *old)\n     ++\t\t\tstrbuf_addstr(params, old);\n     ++\t\tgit_config_append_parameter(params, \"maintenance.auto\", \"false\");\n     ++\t\tgit_config_append_parameter(params, \"gc.auto\", \"0\");\n     ++\t}\n     ++\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, params->buf);\n      +}\n      +\n       /*\n     @@ sequencer.c: static int run_git_commit(const char *defmsg,\n       \t\t\t     author_date_from_env(&cmd.env));\n       \tif (opts->ignore_date)\n       \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n     -+\tif (is_rebase_i(opts))\n     -+\t\tdisable_auto_maintenance(&cmd);\n     ++\tdisable_auto_maintenance(opts, &cmd);\n       \n       \tstrvec_push(&cmd.args, \"commit\");\n       \n     -@@ sequencer.c: static int do_exec(struct repository *r, const char *command_line, int quiet)\n     +@@ sequencer.c: static int error_failed_squash(struct repository *r,\n     + \treturn error_with_patch(r, commit, subject, subject_len, opts, 1, 1);\n     + }\n     + \n     +-static int do_exec(struct repository *r, const char *command_line, int quiet)\n     ++static int do_exec(struct repository *r, const char *command_line,\n     ++\t\t   struct replay_opts *opts)\n     + {\n     + \tstruct child_process cmd = CHILD_PROCESS_INIT;\n     + \tint dirty, status;\n     + \n     +-\tif (!quiet)\n     ++\tif (!opts->quiet)\n     + \t\tfprintf(stderr, _(\"Executing: %s\\n\"), command_line);\n       \tcmd.use_shell = 1;\n       \tstrvec_push(&cmd.args, command_line);\n       \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n     -+\tdisable_auto_maintenance(&cmd);\n     ++\tdisable_auto_maintenance(opts, &cmd);\n       \tstatus = run_command(&cmd);\n       \n       \t/* force re-reading of the cache */\n     @@ sequencer.c: static int do_merge(struct repository *r,\n       \t\t\t\t     author_date_from_env(&cmd.env));\n       \t\tif (opts->ignore_date)\n       \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n     -+\t\tdisable_auto_maintenance(&cmd);\n     ++\t\tdisable_auto_maintenance(opts, &cmd);\n       \n       \t\tcmd.git_cmd = 1;\n       \t\tstrvec_push(&cmd.args, \"merge\");\n     +@@ sequencer.c: static int pick_commits(struct repository *r,\n     + \t\t\tif (!opts->verbose)\n     + \t\t\t\tterm_clear_line();\n     + \t\t\t*end_of_arg = '\\0';\n     +-\t\t\tres = do_exec(r, arg, opts->quiet);\n     ++\t\t\tres = do_exec(r, arg, opts);\n     + \t\t\t*end_of_arg = saved;\n     + \n     + \t\t\tif (res) {\n     +@@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay_opts *opts)\n     + \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n     + \n     + \tcmd.git_cmd = 1;\n     ++\tdisable_auto_maintenance(opts, &cmd);\n     + \tstrvec_push(&cmd.args, \"commit\");\n     + \n     + \t/*\n      \n       ## t/t3418-rebase-continue.sh ##\n      @@ t/t3418-rebase-continue.sh: test_expect_success 'rebase runs auto maintenance at its end' '\n     @@ t/t3418-rebase-continue.sh: test_expect_success 'rebase runs auto maintenance at\n      +'\n      +\n       test_done\n     +\n     + ## t/t3510-cherry-pick-sequence.sh ##\n     +@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n     + \ttest_line_count = 1 maintenance\n     + '\n     + \n     ++test_expect_success 'cherry-pick spawns no auto maintenance before it is done' '\n     ++\tpristine_detach initial &&\n     ++\ttest_must_fail git cherry-pick base..anotherpick &&\n     ++\techo resolved >foo &&\n     ++\tgit add foo &&\n     ++\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n     ++\t\tgit cherry-pick --continue &&\n     ++\ttest_subcommand_flex git commit <mid.txt &&\n     ++\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n     ++\techo d >foo &&\n     ++\tgit add foo &&\n     ++\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --continue &&\n     ++\ttest_subcommand_flex git commit <end.txt &&\n     ++\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n     ++\ttest_line_count = 1 maintenance\n     ++'\n     ++\n     + test_done\n\n-- \ngitgitgadget\n"},{"id":"551976","messageId":"ef8087e80db18c511e31dd9c7dd6ea3d57dd543c.1788537086.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v2.git.1788537086.gitgitgadget@gmail.com","subject":"[PATCH v2 1/3] config: add git_config_append_parameter()","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T15:51:24Z","receivedAt":"2026-09-04T15:51:30Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nSplit the part of git_config_push_split_parameter() that formats one\nGIT_CONFIG_PARAMETERS entry into a helper that appends it to a strbuf,\nso that a caller can build a value for a child's environment without\nknowing the quoting. The sequencer is about to do that.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n config.c | 20 +++++++++++++-------\n config.h | 10 ++++++++++\n 2 files changed, 23 insertions(+), 7 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex d9019e7e6c..e0bb29b53d 100644\n--- a/config.c\n+++ b/config.c\n@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n \treturn ret;\n }\n \n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value)\n+{\n+\tif (env->len)\n+\t\tstrbuf_addch(env, ' ');\n+\tsq_quote_buf(env, key);\n+\tstrbuf_addch(env, '=');\n+\tif (value)\n+\t\tsq_quote_buf(env, value);\n+}\n+\n static void git_config_push_split_parameter(const char *key, const char *value)\n {\n \tstruct strbuf env = STRBUF_INIT;\n \tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n-\tif (old && *old) {\n+\tif (old && *old)\n \t\tstrbuf_addstr(&env, old);\n-\t\tstrbuf_addch(&env, ' ');\n-\t}\n-\tsq_quote_buf(&env, key);\n-\tstrbuf_addch(&env, '=');\n-\tif (value)\n-\t\tsq_quote_buf(&env, value);\n+\tgit_config_append_parameter(&env, key, value);\n \tsetenv(CONFIG_DATA_ENVIRONMENT, env.buf, 1);\n \tstrbuf_release(&env);\n }\ndiff --git a/config.h b/config.h\nindex b66dd08007..fcf48f6245 100644\n--- a/config.h\n+++ b/config.h\n@@ -22,6 +22,7 @@\n  */\n \n struct object_id;\n+struct strbuf;\n \n /* git_config_parse_key() returns these negated: */\n #define CONFIG_INVALID_KEY 1\n@@ -186,6 +187,15 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name,\n \t\t\t     enum config_scope scope);\n void git_config_push_parameter(const char *text);\n void git_config_push_env(const char *spec);\n+\n+/*\n+ * Append `key=value` to the GIT_CONFIG_PARAMETERS value in `env`, quoted\n+ * the way git_config_from_parameters() reads it, so that a child can be\n+ * given configuration on top of what this process was given. A NULL\n+ * `value` appends a boolean entry.\n+ */\n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value);\n int git_config_from_parameters(config_fn_t fn, void *data);\n \n /*\n-- \ngitgitgadget\n\n"},{"id":"551977","messageId":"baab8d4876441ea883044c34bb5584631e30e1ec.1788537086.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v2.git.1788537086.gitgitgadget@gmail.com","subject":"[PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T15:51:25Z","receivedAt":"2026-09-04T15:51:32Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nThe apply backend of \"git rebase\" runs \"git maintenance run --auto\"\nfrom finish_rebase() once it has applied its patches. The merge\nbackend, \"git cherry-pick\" and \"git revert\" do not run it when they\nfinish. They create their commits in process, and only the \"git\ncommit\" they spawn for an edited message or a resolved conflict, the\n\"git merge\" a \"rebase -r\" spawns and an exec command start it, in the\nmiddle of the sequence.\n\nRun it where the sequencer finishes, so that every sequence ends the\nway the apply backend does, and so that the next commit can keep it\nout of the commands a sequence spawns.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                     | 18 +++++++++++++++---\n t/t3418-rebase-continue.sh      |  8 ++++++++\n t/t3510-cherry-pick-sequence.sh | 10 ++++++++++\n 3 files changed, 33 insertions(+), 3 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 65afd100d9..67e1c38762 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -5313,6 +5313,12 @@ cleanup_head_ref:\n \t\t\treturn -1;\n \t}\n \n+\t/*\n+\t * We ignore errors in 'git maintenance run --auto', since the\n+\t * user should see them.\n+\t */\n+\trun_auto_maintenance(r, opts->quiet);\n+\n \t/*\n \t * Sequence of picks finished successfully; cleanup by\n \t * removing the .git/sequencer directory\n@@ -5577,10 +5583,14 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)\n \t\t\tres = -1;\n \t\t\tgoto release_todo_list;\n \t\t}\n-\t} else if (!file_exists(get_todo_path(opts)))\n-\t\treturn continue_single_pick(r, opts);\n-\telse if ((res = read_populate_todo(r, &todo_list, opts)))\n+\t} else if (!file_exists(get_todo_path(opts))) {\n+\t\tres = continue_single_pick(r, opts);\n+\t\tif (!res)\n+\t\t\trun_auto_maintenance(r, opts->quiet);\n+\t\treturn res;\n+\t} else if ((res = read_populate_todo(r, &todo_list, opts))) {\n \t\tgoto release_todo_list;\n+\t}\n \n \tif (!is_rebase_i(opts)) {\n \t\t/* Verify that the conflict has been resolved */\n@@ -5698,6 +5708,8 @@ int sequencer_pick_revisions(struct repository *r,\n \t\t\tBUG(\"unexpected extra commit from walk\");\n \n \t\tres = single_pick(r, cmit, opts);\n+\t\tif (!res)\n+\t\t\trun_auto_maintenance(r, opts->quiet);\n \t\tgoto out;\n \t}\n \ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex cb5c3a1cb5..2c34cf8a01 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -395,4 +395,12 @@ test_orig_head () {\n test_orig_head --apply\n test_orig_head --merge\n \n+test_expect_success 'rebase runs auto maintenance at its end' '\n+\tgit checkout -b one-exec main^ &&\n+\ttest_commit F4 &&\n+\ttest_must_fail git rebase -x false main &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/finish.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <finish.txt\n+'\n+\n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 5777dff496..304981ccd6 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -721,4 +721,14 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \ttest_line_count = 4 commits\n '\n \n+test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n+\tpristine_detach base &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n+\t\tgit cherry-pick anotherpick yetanotherpick &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"551978","messageId":"9a6fc0427a8bc7e7abcc0518214b1dafc2efaa6a.1788537086.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v2.git.1788537086.gitgitgadget@gmail.com","subject":"[PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-04T15:51:26Z","receivedAt":"2026-09-04T15:51:33Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nThe \"git commit\" and \"git merge\" the sequencer spawns, and the git\ncommands an exec runs, each start \"git maintenance run --auto\n--detach\", which then works in the background against the sequence\nitself. A \"rerere gc\" started by the commit of one \"git rebase\n--continue\" holds MERGE_RR.lock when the next pick needs it, and a\nrepack deletes packs the sequencer still has open, which 65cda10d5b\n(sequencer: release the ODB before spawning git commit, 2026-08-12)\nhad to work around.\n\nThe loose objects a sequence creates wait for the run at its end that\nthe previous commit added. Whether a sequence can be long enough to\nsuffer from them before that remains to be seen. Pass\nmaintenance.auto=false and gc.auto=0 to the spawned commands through\nGIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to\nwhatever it runs, appended after the user's own -c settings so that\nours win, and built once per run. A command the user runs while the\nsequence is stopped, like \"git commit --amend\" at an edit, is not the\nsequencer's to control and still runs maintenance.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                     | 39 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 18 +++++++++++++++\n t/t3510-cherry-pick-sequence.sh | 17 ++++++++++++++\n 3 files changed, 71 insertions(+), 3 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 67e1c38762..5df07750a7 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -234,6 +234,11 @@ struct replay_ctx {\n \t * Whether message contains a commit message.\n \t */\n \tunsigned have_message :1;\n+\t/*\n+\t * The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out\n+\t * of the commands we spawn, built on first use.\n+\t */\n+\tstruct strbuf config_parameters;\n };\n \n struct replay_ctx* replay_ctx_new(void)\n@@ -242,6 +247,7 @@ struct replay_ctx* replay_ctx_new(void)\n \n \tstrbuf_init(&ctx->current_fixups, 0);\n \tstrbuf_init(&ctx->message, 0);\n+\tstrbuf_init(&ctx->config_parameters, 0);\n \n \treturn ctx;\n }\n@@ -407,6 +413,7 @@ static void replay_ctx_release(struct replay_ctx *ctx)\n {\n \tstrbuf_release(&ctx->current_fixups);\n \tstrbuf_release(&ctx->message);\n+\tstrbuf_release(&ctx->config_parameters);\n }\n \n void replay_opts_release(struct replay_opts *opts)\n@@ -1107,6 +1114,27 @@ static int run_command_silent_on_success(struct child_process *cmd)\n \treturn rc;\n }\n \n+/*\n+ * A sequence runs auto maintenance once it is done, not from every command\n+ * it spawns along the way: their background \"rerere gc\" or repack would\n+ * race the sequencer for locks and files it still holds.\n+ */\n+static void disable_auto_maintenance(struct replay_opts *opts,\n+\t\t\t\t     struct child_process *cmd)\n+{\n+\tstruct strbuf *params = &opts->ctx->config_parameters;\n+\n+\tif (!params->len) {\n+\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n+\n+\t\tif (old && *old)\n+\t\t\tstrbuf_addstr(params, old);\n+\t\tgit_config_append_parameter(params, \"maintenance.auto\", \"false\");\n+\t\tgit_config_append_parameter(params, \"gc.auto\", \"0\");\n+\t}\n+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, params->buf);\n+}\n+\n /*\n  * If we are cherry-pick, and if the merge did not result in\n  * hand-editing, we will hit this commit and inherit the original\n@@ -1148,6 +1176,7 @@ static int run_git_commit(const char *defmsg,\n \t\t\t     author_date_from_env(&cmd.env));\n \tif (opts->ignore_date)\n \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \n \tstrvec_push(&cmd.args, \"commit\");\n \n@@ -3924,16 +3953,18 @@ static int error_failed_squash(struct repository *r,\n \treturn error_with_patch(r, commit, subject, subject_len, opts, 1, 1);\n }\n \n-static int do_exec(struct repository *r, const char *command_line, int quiet)\n+static int do_exec(struct repository *r, const char *command_line,\n+\t\t   struct replay_opts *opts)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tint dirty, status;\n \n-\tif (!quiet)\n+\tif (!opts->quiet)\n \t\tfprintf(stderr, _(\"Executing: %s\\n\"), command_line);\n \tcmd.use_shell = 1;\n \tstrvec_push(&cmd.args, command_line);\n \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstatus = run_command(&cmd);\n \n \t/* force re-reading of the cache */\n@@ -4342,6 +4373,7 @@ static int do_merge(struct repository *r,\n \t\t\t\t     author_date_from_env(&cmd.env));\n \t\tif (opts->ignore_date)\n \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\t\tdisable_auto_maintenance(opts, &cmd);\n \n \t\tcmd.git_cmd = 1;\n \t\tstrvec_push(&cmd.args, \"merge\");\n@@ -5158,7 +5190,7 @@ static int pick_commits(struct repository *r,\n \t\t\tif (!opts->verbose)\n \t\t\t\tterm_clear_line();\n \t\t\t*end_of_arg = '\\0';\n-\t\t\tres = do_exec(r, arg, opts->quiet);\n+\t\t\tres = do_exec(r, arg, opts);\n \t\t\t*end_of_arg = saved;\n \n \t\t\tif (res) {\n@@ -5335,6 +5367,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \n \tcmd.git_cmd = 1;\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstrvec_push(&cmd.args, \"commit\");\n \n \t/*\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 2c34cf8a01..cf6d20ce79 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' '\n \ttest_subcommand_flex git maintenance run --auto <finish.txt\n '\n \n+test_expect_success 'rebase spawns no auto maintenance before its end' '\n+\tgit checkout -b two-conflicts topic &&\n+\ttest_commit F2-again F2 222 &&\n+\ttest_must_fail git rebase -x \"git commit --allow-empty -m exec\" main &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit rebase --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 304981ccd6..57a77d91bd 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -731,4 +731,21 @@ test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n \ttest_line_count = 1 maintenance\n '\n \n+test_expect_success 'cherry-pick spawns no auto maintenance before it is done' '\n+\tpristine_detach initial &&\n+\ttest_must_fail git cherry-pick base..anotherpick &&\n+\techo resolved >foo &&\n+\tgit add foo &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit cherry-pick --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n+\techo d >foo &&\n+\tgit add foo &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --continue &&\n+\ttest_subcommand_flex git commit <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n test_done\n-- \ngitgitgadget\n"},{"id":"551980","messageId":"CAA0xjto-UKzHT2he5U25_G1B__z59jHdgit7A6Za7U=htra3ag@mail.gmail.com","threadId":"66269","inReplyTo":"f44765f2-d04f-4adc-b5f0-56a22658626b@gmail.com","subject":"Re: [PATCH 2/2] sequencer: keep auto maintenance out of the commands a rebase spawns","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-04T15:55:20Z","receivedAt":"2026-09-04T15:55:36Z","isPatch":true,"body":"Hi Phillip,\n\nOn 04/09/2026 16:03, Phillip Wood wrote:\n> That's what we'll find out when this is merged.\n\nAgreed, and the message now says so instead of claiming it.\n\n> I'm inclined to think that the reasoning for running maintenance at the\n> end of a rebase applies to cherry-pick and probably revert as well.\n\nAgreed. In v2 all three end with one run where the sequencer finishes,\nand none of the commands they spawn run it, the \"git commit\" of a\n\"cherry-pick --continue\" included.\n\n> I wonder if we could factor out a helper append the parameters to an\n> strbuf passed by the caller so we don't need to know about the quoting\n> scheme here. Also it would be nice to cache this in replay_ctx so we\n> don't have to construct the string each time we want to disable auto\n> maintenance.\n\nDone, as a small config.c patch in front of the two, and a strbuf in\nreplay_ctx built on first use.\n\nThe messages are rewritten from scratch and much shorter, the sentence\nyou could not parse included.\n\nThanks,\nThomas\n"},{"id":"552004","messageId":"xmqqwlt03e6k.fsf@gitster.g","threadId":"66269","inReplyTo":"9a6fc0427a8bc7e7abcc0518214b1dafc2efaa6a.1788537086.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-04T21:21:55Z","receivedAt":"2026-09-04T21:21:59Z","isPatch":true,"body":"\"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\t/*\n> +\t * The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out\n> +\t * of the commands we spawn, built on first use.\n> +\t */\n> +\tstruct strbuf config_parameters;\n\nDoes this have to be a \"struct strbuf\", not \"const char *\"?  The\nlatter makes it clear that it will never change its value once you\nbuilt it in disable_auto_maintenance().\n\n> +static void disable_auto_maintenance(struct replay_opts *opts,\n> +\t\t\t\t     struct child_process *cmd)\n> +{\n> +\tstruct strbuf *params = &opts->ctx->config_parameters;\n> +\n> +\tif (!params->len) {\n> +\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n> +\n> +\t\tif (old && *old)\n> +\t\t\tstrbuf_addstr(params, old);\n> +\t\tgit_config_append_parameter(params, \"maintenance.auto\", \"false\");\n> +\t\tgit_config_append_parameter(params, \"gc.auto\", \"0\");\n> +\t}\n> +\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, params->buf);\n> +}\n\nThis would then become something like\n\n\tif (!opts->ctx->config_parameters) {\n\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n\t\tstruct strbuf params = STRBUF_INIT;\n\n                if (old && *old)\n\t\t\tstrbuf_addstr(&params, old);\n\t\tgit_config_append_parameter(&params, \"maintenance.auto\", \"0\");\n\t\tgit_config_append_parameter(&params, \"gc.auto\", \"0\");\n\t\topts->ctx->config_parameters = strbuf_detach(&params, NULL);\n\t}\n\tstrbuf_pushf(..., opts->ctx->config_parameters);\n\n"},{"id":"552021","messageId":"CAA0xjtokUaNPxwucZ6p_-G6DsmEMsX9JfR4UOwZK=crvEd5fAQ@mail.gmail.com","threadId":"66269","inReplyTo":"xmqqwlt03e6k.fsf@gitster.g","subject":"Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-05T05:42:02Z","receivedAt":"2026-09-05T05:42:15Z","isPatch":true,"body":"Hi Junio,\n\nOn 04/09/2026 23:21, Junio C Hamano wrote:\n> Does this have to be a \"struct strbuf\", not \"const char *\"?  The\n> latter makes it clear that it will never change its value once you\n> built it in disable_auto_maintenance().\n\nIt doesn't. I'll make it a char * that replay_ctx_release() frees,\nbuilt the way you sketch, in the next version.\n\nThanks,\nThomas\n"},{"id":"552100","messageId":"ap5yT0sOtLQQa4AY@pks.im","threadId":"66269","inReplyTo":"ef8087e80db18c511e31dd9c7dd6ea3d57dd543c.1788537086.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/3] config: add git_config_append_parameter()","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-07T08:14:07Z","receivedAt":"2026-09-07T08:14:14Z","isPatch":true,"body":"On Fri, Sep 04, 2026 at 03:51:24PM +0000, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> Split the part of git_config_push_split_parameter() that formats one\n> GIT_CONFIG_PARAMETERS entry into a helper that appends it to a strbuf,\n> so that a caller can build a value for a child's environment without\n> knowing the quoting. The sequencer is about to do that.\n\nReaders who don't have any context around GIT_CONFIG_PARAMETERS and what\nit does will have a bit of a hard time making much sense of this, I\nthink. It usually helps to give a sentence or two explaining what the\ninfra even does, and what this quoting looks like.\n\n> Assisted-by: Claude Fable 5.1\n> Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n> ---\n>  config.c | 20 +++++++++++++-------\n>  config.h | 10 ++++++++++\n>  2 files changed, 23 insertions(+), 7 deletions(-)\n> \n> diff --git a/config.c b/config.c\n> index d9019e7e6c..e0bb29b53d 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n>  \treturn ret;\n>  }\n>  \n> +void git_config_append_parameter(struct strbuf *env, const char *key,\n\nNit: callling this `env` assumes a bit too much about what this buffer\nis going to be used for. I'd have called it just `buf`.\n\n> diff --git a/config.h b/config.h\n> index b66dd08007..fcf48f6245 100644\n> --- a/config.h\n> +++ b/config.h\n> @@ -22,6 +22,7 @@\n>   */\n>  \n>  struct object_id;\n> +struct strbuf;\n>  \n>  /* git_config_parse_key() returns these negated: */\n>  #define CONFIG_INVALID_KEY 1\n> @@ -186,6 +187,15 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name,\n>  \t\t\t     enum config_scope scope);\n>  void git_config_push_parameter(const char *text);\n>  void git_config_push_env(const char *spec);\n> +\n> +/*\n> + * Append `key=value` to the GIT_CONFIG_PARAMETERS value in `env`, quoted\n> + * the way git_config_from_parameters() reads it, so that a child can be\n> + * given configuration on top of what this process was given. A NULL\n> + * `value` appends a boolean entry.\n> + */\n> +void git_config_append_parameter(struct strbuf *env, const char *key,\n> +\t\t\t\t const char *value);\n\nPointing to that other function makes sense, but neither of the\nfunctions documents the actual format that's used.\n\nPatrick\n"},{"id":"552101","messageId":"ap5yVFNEFm2vdP1B@pks.im","threadId":"66269","inReplyTo":"baab8d4876441ea883044c34bb5584631e30e1ec.1788537086.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-07T08:14:12Z","receivedAt":"2026-09-07T08:14:17Z","isPatch":true,"body":"On Fri, Sep 04, 2026 at 03:51:25PM +0000, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> The apply backend of \"git rebase\" runs \"git maintenance run --auto\"\n> from finish_rebase() once it has applied its patches. The merge\n> backend, \"git cherry-pick\" and \"git revert\" do not run it when they\n> finish. They create their commits in process, and only the \"git\n> commit\" they spawn for an edited message or a resolved conflict, the\n> \"git merge\" a \"rebase -r\" spawns and an exec command start it, in the\n> middle of the sequence.\n\nThis paragraph just doesn't parse for me, it's really hard to tell what\nit even wants to say.\n\n> Run it where the sequencer finishes, so that every sequence ends the\n> way the apply backend does, and so that the next commit can keep it\n> out of the commands a sequence spawns.\n\nBesides moving stuff around to prep for the next commit, what does this\nchange? Like, do we now run the command in cases where we didn't before?\nAnd if so, what are the consequences of doing so?\n\n> diff --git a/sequencer.c b/sequencer.c\n> index 65afd100d9..67e1c38762 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -5313,6 +5313,12 @@ cleanup_head_ref:\n>  \t\t\treturn -1;\n>  \t}\n>  \n> +\t/*\n> +\t * We ignore errors in 'git maintenance run --auto', since the\n> +\t * user should see them.\n> +\t */\n> +\trun_auto_maintenance(r, opts->quiet);\n> +\n>  \t/*\n>  \t * Sequence of picks finished successfully; cleanup by\n>  \t * removing the .git/sequencer directory\n> @@ -5577,10 +5583,14 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)\n>  \t\t\tres = -1;\n>  \t\t\tgoto release_todo_list;\n>  \t\t}\n> -\t} else if (!file_exists(get_todo_path(opts)))\n> -\t\treturn continue_single_pick(r, opts);\n> -\telse if ((res = read_populate_todo(r, &todo_list, opts)))\n> +\t} else if (!file_exists(get_todo_path(opts))) {\n> +\t\tres = continue_single_pick(r, opts);\n> +\t\tif (!res)\n> +\t\t\trun_auto_maintenance(r, opts->quiet);\n> +\t\treturn res;\n> +\t} else if ((res = read_populate_todo(r, &todo_list, opts))) {\n>  \t\tgoto release_todo_list;\n> +\t}\n>  \n>  \tif (!is_rebase_i(opts)) {\n>  \t\t/* Verify that the conflict has been resolved */\n> @@ -5698,6 +5708,8 @@ int sequencer_pick_revisions(struct repository *r,\n>  \t\t\tBUG(\"unexpected extra commit from walk\");\n>  \n>  \t\tres = single_pick(r, cmit, opts);\n> +\t\tif (!res)\n> +\t\t\trun_auto_maintenance(r, opts->quiet);\n>  \t\tgoto out;\n>  \t}\n>  \n\nIt's surprisingly many sites where you add the call to\n`run_auto_maintenance()`. My hope was that there is a single exit path\nsomewhere that is used by both the \"apply\" and \"merge\" strategy that we\ncould adapt to unify when exactly we run auto-maintenance across both\nbackends.\n\nPatrick\n"},{"id":"552102","messageId":"ap5yWS5tKLej7BjT@pks.im","threadId":"66269","inReplyTo":"9a6fc0427a8bc7e7abcc0518214b1dafc2efaa6a.1788537086.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-07T08:14:17Z","receivedAt":"2026-09-07T08:14:22Z","isPatch":true,"body":"On Fri, Sep 04, 2026 at 03:51:26PM +0000, Thomas Bachem via GitGitGadget wrote:\n> diff --git a/sequencer.c b/sequencer.c\n> index 67e1c38762..5df07750a7 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -1107,6 +1114,27 @@ static int run_command_silent_on_success(struct child_process *cmd)\n>  \treturn rc;\n>  }\n>  \n> +/*\n> + * A sequence runs auto maintenance once it is done, not from every command\n> + * it spawns along the way: their background \"rerere gc\" or repack would\n> + * race the sequencer for locks and files it still holds.\n> + */\n> +static void disable_auto_maintenance(struct replay_opts *opts,\n> +\t\t\t\t     struct child_process *cmd)\n> +{\n> +\tstruct strbuf *params = &opts->ctx->config_parameters;\n> +\n> +\tif (!params->len) {\n> +\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n> +\n> +\t\tif (old && *old)\n> +\t\t\tstrbuf_addstr(params, old);\n> +\t\tgit_config_append_parameter(params, \"maintenance.auto\", \"false\");\n> +\t\tgit_config_append_parameter(params, \"gc.auto\", \"0\");\n> +\t}\n> +\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, params->buf);\n> +}\n> +\n\nWhy do you set both \"maintenance.auto\" and \"gc.auto\"? Setting only the\nformer should be sufficient, as maintenance uses git-maintenance(1)\nexclusively nowadays. Sure, it may trigger git-gc(1) internally. But it\nwon't ever do so if auto-maintenance is completely disabled.\n\nPatrick\n"},{"id":"552139","messageId":"7493f0b7-a6cb-4b7d-bfd4-f4a318ff7e32@gmail.com","threadId":"66269","inReplyTo":"9a6fc0427a8bc7e7abcc0518214b1dafc2efaa6a.1788537086.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-07T13:24:13Z","receivedAt":"2026-09-07T13:24:21Z","isPatch":true,"body":"\n\nOn 04/09/2026 16:51, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> The \"git commit\" and \"git merge\" the sequencer spawns, and the git\n> commands an exec runs, each start \"git maintenance run --auto\n> --detach\", which then works in the background against the sequence\n> itself. \n\nI don't think maintenance is actively working against other commands, it \njust creates lock contention. Maybe something like\n\n     When the sequencer runs \"git commit\" or \"git merge\", either directly\n     or via a user supplied exec command, those commands run \"git\n     maintenance --auto --detach\" which can cause lock contention with\n     the sequencer.\n\n> A \"rerere gc\" started by the commit of one \"git rebase\n> --continue\" holds MERGE_RR.lock when the next pick needs it, and a\n> repack deletes packs the sequencer still has open, which 65cda10d5b\n> (sequencer: release the ODB before spawning git commit, 2026-08-12)\n> had to work around.\n\nThis is pretty hard to understand. What does 'the commit of one \"git \nrebase --continue\"' mean? Also whether the next pick needs to take \nMERGE_RR.lock is conditional on there being conflicts which isn't at all \nclear.\n> The loose objects a sequence creates wait for the run at its end that\n> the previous commit added.\n\nWhat does that mean?\n\n> Whether a sequence can be long enough to\n> suffer from them before that remains to be seen. Pass\n> maintenance.auto=false and gc.auto=0 to the spawned commands through\n> GIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to\n> whatever it runs,\n\nTalking about the shell here is unnecessarily confusing as the command \nis not necessarily run by the shell: if it is a single word that does \nnot contain any shell metacharacters it is passed directly to exec()\n\n> appended after the user's own -c settings so that\n> ours win, and built once per run. A command the user runs while the\n> sequence is stopped, like \"git commit --amend\" at an edit, is not the\n> sequencer's to control and still runs maintenance.\n> \n\n> @@ -1107,6 +1114,27 @@ static int run_command_silent_on_success(struct child_process *cmd)\n>   \treturn rc;\n>   }\n>   \n> +/*\n> + * A sequence runs auto maintenance once it is done, not from every command\n> + * it spawns along the way: their background \"rerere gc\" or repack would\n> + * race the sequencer for locks and files it still holds.\n> + */\n\nThis comment isn't wrong but sounds like an LLM, rather than something a \nperson would write.\n\n> +static void disable_auto_maintenance(struct replay_opts *opts,\n> +\t\t\t\t     struct child_process *cmd)\n> +{\n> +\tstruct strbuf *params = &opts->ctx->config_parameters;\n> +\n> +\tif (!params->len) {\n> +\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n> +\n> +\t\tif (old && *old)\n> +\t\t\tstrbuf_addstr(params, old);\n> +\t\tgit_config_append_parameter(params, \"maintenance.auto\", \"false\");\n> +\t\tgit_config_append_parameter(params, \"gc.auto\", \"0\");\n\nThis is much nicer now we have the helper function and the calls to \ndisable_auto_maintenance() that I've trimmed all look good.\n> diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\n> index 2c34cf8a01..cf6d20ce79 100755\n> --- a/t/t3418-rebase-continue.sh\n> +++ b/t/t3418-rebase-continue.sh\n> @@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' '\n>   \ttest_subcommand_flex git maintenance run --auto <finish.txt\n>   '\n>   \n> +test_expect_success 'rebase spawns no auto maintenance before its end' '\n> +\tgit checkout -b two-conflicts topic &&\n> +\ttest_commit F2-again F2 222 &&\n> +\ttest_must_fail git rebase -x \"git commit --allow-empty -m exec\" main &&\n> +\techo resolved >F2 &&\n> +\tgit add F2 &&\n> +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n> +\t\tgit rebase --continue &&\n> +\ttest_subcommand_flex git commit <mid.txt &&\n> +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n> +\techo resolved >F2 &&\n> +\tgit add F2 &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n> +\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n> +\ttest_line_count = 1 maintenance\n\nShouldn't this just extend the test added in the previous patch, rather \nthan duplicating the coverage for auto maintenance being run at the end \nof a rebase?\n\n> +'\n> +\n>   test_done\n> diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\n> index 304981ccd6..57a77d91bd 100755\n> --- a/t/t3510-cherry-pick-sequence.sh\n> +++ b/t/t3510-cherry-pick-sequence.sh\n> @@ -731,4 +731,21 @@ test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n>   \ttest_line_count = 1 maintenance\n>   '\n>   \n> +test_expect_success 'cherry-pick spawns no auto maintenance before it is done' '\n> +\tpristine_detach initial &&\n> +\ttest_must_fail git cherry-pick base..anotherpick &&\n> +\techo resolved >foo &&\n> +\tgit add foo &&\n> +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n> +\t\tgit cherry-pick --continue &&\n> +\ttest_subcommand_flex git commit <mid.txt &&\n> +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n> +\techo d >foo &&\n> +\tgit add foo &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --continue &&\n> +\ttest_subcommand_flex git commit <end.txt &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n> +\ttest_line_count = 1 maintenance\n\nAgain why do we need a separate test, rather than extending the one \nwe've just added in the previous commit?\n\nThanks\n\nPhillip\n\n> +'\n> +\n>   test_done\n\n"},{"id":"552140","messageId":"b395ea0d-37aa-471a-a70a-6b2c278ad64e@gmail.com","threadId":"66269","inReplyTo":"ap5yT0sOtLQQa4AY@pks.im","subject":"Re: [PATCH v2 1/3] config: add git_config_append_parameter()","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-07T13:24:34Z","receivedAt":"2026-09-07T13:24:40Z","isPatch":true,"body":"On 07/09/2026 09:14, Patrick Steinhardt wrote:\n> On Fri, Sep 04, 2026 at 03:51:24PM +0000, Thomas Bachem via GitGitGadget wrote:\n>> From: Thomas Bachem <mail@thomasbachem.com>\n>>\n>> diff --git a/config.c b/config.c\n>> index d9019e7e6c..e0bb29b53d 100644\n>> --- a/config.c\n>> +++ b/config.c\n>> @@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n>>   \treturn ret;\n>>   }\n>>   \n>> +void git_config_append_parameter(struct strbuf *env, const char *key,\n> \n> Nit: callling this `env` assumes a bit too much about what this buffer\n> is going to be used for. I'd have called it just `buf`.\n\nAre we ever likely to use this outside of GIT_CONFIG_PARAMETERS? If not \nthen I think env is a good name because it hints at where this function \nis used. Isn't the whole point of this function to allow us to append \nsettings an environment variable?\n\nThanks\n\nPhillip\n\n"},{"id":"552141","messageId":"d09ef622-1398-4e38-8a04-8542e7347a98@gmail.com","threadId":"66269","inReplyTo":"baab8d4876441ea883044c34bb5584631e30e1ec.1788537086.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-07T13:25:47Z","receivedAt":"2026-09-07T13:25:52Z","isPatch":true,"body":"Hi Thomas\n\nOn 04/09/2026 16:51, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> The apply backend of \"git rebase\" runs \"git maintenance run --auto\"\n> from finish_rebase() once it has applied its patches. The merge\n> backend, \"git cherry-pick\" and \"git revert\" do not run it when they\n\n     The merge backend which is also used by \"git cherry-pick\" and \"git\n     revert\" does not run it when it finishes.\n\nwould be clearer to me\n\n> finish. They create their commits in process, and only the \"git\n> commit\" they spawn for an edited message or a resolved conflict, the\n> \"git merge\" a \"rebase -r\" spawns and an exec command start it, in the\n> middle of the sequence.\n\nLike Patrick I cannot understand what this is saying, let alone whether \nit is saying anything useful.\n\n\n> Run it where the sequencer finishes, so that every sequence ends the\n> way the apply backend does, and so that the next commit can keep it\n> out of the commands a sequence spawns.\n\n     Run \"git maintenace --auto\" at the end of all sequencer operations,\n     ...\n\nwould be clearer to me\n\n> diff --git a/sequencer.c b/sequencer.c\n> index 65afd100d9..67e1c38762 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -5313,6 +5313,12 @@ cleanup_head_ref:\n\nThis makes me think we should change the fragment re for c files to \nexclude ':', but that's a digression and would mean having different \nexpressions for c and c++.\n\nAnyway this change is at the end of pick_commits(), just before we \nfinish so looks like the right place to call run_auto_maintenance()\n\n>   \t\t\treturn -1;\n>   \t}\n>   \n> +\t/*\n> +\t * We ignore errors in 'git maintenance run --auto', since the\n> +\t * user should see them.\n> +\t */\n> +\trun_auto_maintenance(r, opts->quiet);\n> +\n>   \t/*\n>   \t * Sequence of picks finished successfully; cleanup by\n>   \t * removing the .git/sequencer directory\n> @@ -5577,10 +5583,14 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)\n>   \t\t\tres = -1;\n>   \t\t\tgoto release_todo_list;\n>   \t\t}\n> -\t} else if (!file_exists(get_todo_path(opts)))\n> -\t\treturn continue_single_pick(r, opts);\n> -\telse if ((res = read_populate_todo(r, &todo_list, opts)))\n> +\t} else if (!file_exists(get_todo_path(opts))) {\n> +\t\tres = continue_single_pick(r, opts);\n\nIt is a shame the single pick variants of \"git cherry-pick\" and \"git \nrevert\" do not share the same code path as the multiple pick variants. \ncontinue_single_pick() runs \"git commit\" without calling \nrun_git_commit() which is also unfortunate, but means that we could just \nrely and \"git commit\" to call run_auto_maintenance() for us.\n\n> +\t\tif (!res)\n> +\t\t\trun_auto_maintenance(r, opts->quiet);\n> +\t\treturn res;\n> +\t} else if ((res = read_populate_todo(r, &todo_list, opts))) {\n>   \t\tgoto release_todo_list;\n> +\t}\n>   \n>   \tif (!is_rebase_i(opts)) {\n>   \t\t/* Verify that the conflict has been resolved */\n> @@ -5698,6 +5708,8 @@ int sequencer_pick_revisions(struct repository *r,\n>   \t\t\tBUG(\"unexpected extra commit from walk\");\n>   \n>   \t\tres = single_pick(r, cmit, opts);\n> +\t\tif (!res)\n> +\t\t\trun_auto_maintenance(r, opts->quiet);\n>   \t\tgoto out;\n>   \t}\n>   \n> diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\n> index cb5c3a1cb5..2c34cf8a01 100755\n> --- a/t/t3418-rebase-continue.sh\n> +++ b/t/t3418-rebase-continue.sh\n> @@ -395,4 +395,12 @@ test_orig_head () {\n>   test_orig_head --apply\n>   test_orig_head --merge\n>   \n> +test_expect_success 'rebase runs auto maintenance at its end' '\n> +\tgit checkout -b one-exec main^ &&\n> +\ttest_commit F4 &&\n> +\ttest_must_fail git rebase -x false main &&\n\nDo we want to assert that we don't run auto maintenance up to this point?\n\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/finish.txt\" git rebase --continue &&\n> +\ttest_subcommand_flex git maintenance run --auto <finish.txt\n> +'\n> +\n>   test_done\n> diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\n> index 5777dff496..304981ccd6 100755\n> --- a/t/t3510-cherry-pick-sequence.sh\n> +++ b/t/t3510-cherry-pick-sequence.sh\n> @@ -721,4 +721,14 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n>   \ttest_line_count = 4 commits\n>   '\n>   \n> +test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n> +\tpristine_detach base &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n> +\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n> +\t\tgit cherry-pick anotherpick yetanotherpick &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n\nUsing test_grep here would mean we get some useful test output if there \nare not matches in the file. Without that test_line_count just says the \nline count didn't match and prints an empty file.\n\n\nThanks\n\nPhillip\n\n> +\ttest_line_count = 1 maintenance\n> +'\n> +\n>   test_done\n\n"},{"id":"552144","messageId":"ap7Ol5baYwXTn6R_@pks.im","threadId":"66269","inReplyTo":"b395ea0d-37aa-471a-a70a-6b2c278ad64e@gmail.com","subject":"Re: [PATCH v2 1/3] config: add git_config_append_parameter()","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-07T14:47:51Z","receivedAt":"2026-09-07T14:47:59Z","isPatch":true,"body":"On Mon, Sep 07, 2026 at 02:24:34PM +0100, Phillip Wood wrote:\n> On 07/09/2026 09:14, Patrick Steinhardt wrote:\n> > On Fri, Sep 04, 2026 at 03:51:24PM +0000, Thomas Bachem via GitGitGadget wrote:\n> > > From: Thomas Bachem <mail@thomasbachem.com>\n> > > \n> > > diff --git a/config.c b/config.c\n> > > index d9019e7e6c..e0bb29b53d 100644\n> > > --- a/config.c\n> > > +++ b/config.c\n> > > @@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n> > >   \treturn ret;\n> > >   }\n> > > +void git_config_append_parameter(struct strbuf *env, const char *key,\n> > \n> > Nit: callling this `env` assumes a bit too much about what this buffer\n> > is going to be used for. I'd have called it just `buf`.\n> \n> Are we ever likely to use this outside of GIT_CONFIG_PARAMETERS? If not then\n> I think env is a good name because it hints at where this function is used.\n> Isn't the whole point of this function to allow us to append settings an\n> environment variable?\n\nPotentially, even though this function doesn't really require that at\nall. So it may or may not be used outside this current use case.\n\nAnway, as I've said it's only a nit, so I won't insist on a change here.\n\nPatrick\n"},{"id":"552146","messageId":"CAA0xjtqy3jOPWAGL9Cr0B+VnHAkZF0=cVCxKNqMiVJpfbdpomA@mail.gmail.com","threadId":"66269","inReplyTo":"ap5yVFNEFm2vdP1B@pks.im","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-07T16:35:20Z","receivedAt":"2026-09-07T16:35:32Z","isPatch":true,"body":"Hi Patrick,\n\nOn 07/09/2026 10:14, Patrick Steinhardt wrote:\n> This paragraph just doesn't parse for me, it's really hard to tell what\n> it even wants to say.\n\nSorry, I'll rewrite it. What I meant: the apply backend runs auto\nmaintenance from finish_rebase() when it is done. The merge backend,\ncherry-pick and revert create their commits in process and never run\nit themselves. It only runs when they spawn a command that runs it\nanyway: \"git commit\" for an edited message or a resolved conflict,\n\"git merge\" for an octopus merge or a custom strategy in \"rebase -r\",\nor a git command in an exec. So a clean sequence never runs it, and\none with conflicts runs it after each resolution, in the middle of the\nsequence.\n\n> Besides moving stuff around to prep for the next commit, what does this\n> change? Like, do we now run the command in cases where we didn't before?\n> And if so, what are the consequences of doing so?\n\nYes. After this patch every sequence that finishes runs it at the end,\nlike a \"git commit\" or an apply backend rebase does. The next patch\nstops the runs in the middle, so it ends up as one run per sequence.\nThe case that changes is a sequence with no conflict to resolve and no\nmessage to edit. Such a sequence never ran it at all, so its loose\nobjects waited for the next commit. It is the same\n\"git maintenance run --auto --detach\" as after a commit, so it runs in\nthe background and does nothing unless a threshold is met. I'll put\nthat in the message.\n\n> It's surprisingly many sites where you add the call to\n> `run_auto_maintenance()`. My hope was that there is a single exit path\n> somewhere that is used by both the \"apply\" and \"merge\" strategy that we\n> could adapt to unify when exactly we run auto-maintenance across both\n> backends.\n\nThere is none inside the sequencer. run_specific_rebase() calls\nfinish_rebase() for the apply backend only,\n\"merge backend cleans up after itself\" as the comment there says.\nSequences end inside pick_commits(), and a single cherry-pick or\nrevert never creates sequencer state at all and returns straight to\nbuiltin/revert.c. That is where the three sites come from.\n\nI could instead do what the apply backend already does. am.c skips\nmaintenance in rebasing mode and leaves it to rebase.c. If the\nsequencer leaves it to its callers the same way, run_specific_rebase()\nruns it for the merge backend too, once its state directory is gone,\nand run_sequencer() in builtin/revert.c runs it for cherry-pick and\nrevert. Every entry into the merge backend returns through\nrun_specific_rebase(), --continue and --skip included, so nothing is\nmissed. The sequencer then never runs it, the change is in the two\nbuiltins only, and the rule is short: the command runs it once when it\nis done, and nothing it spawns does. Is that what you had in mind?\n\nThanks,\nThomas\n"},{"id":"552147","messageId":"CAA0xjtrherFZZBSeqE8zd6Kbwy_=f9mwiqJK832DzZRakkiwBw@mail.gmail.com","threadId":"66269","inReplyTo":"ap5yWS5tKLej7BjT@pks.im","subject":"Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-07T16:35:47Z","receivedAt":"2026-09-07T16:35:59Z","isPatch":true,"body":"Hi Patrick,\n\nOn 07/09/2026 10:14, Patrick Steinhardt wrote:\n> Why do you set both \"maintenance.auto\" and \"gc.auto\"? Setting only the\n> former should be sufficient, as maintenance uses git-maintenance(1)\n> exclusively nowadays. Sure, it may trigger git-gc(1) internally. But it\n> won't ever do so if auto-maintenance is completely disabled.\n\nYou're right. prepare_auto_maintenance() looks at gc.auto only when\nmaintenance.auto is unset, so maintenance.auto alone is enough.\ngc.auto=0 would still stop an exec that runs \"git gc --auto\" itself,\nbut I don't think we need to guard against that. I'll drop it in v3.\n\nThanks,\nThomas\n"},{"id":"552148","messageId":"CAA0xjto++XQ6SZVfr5hWq2+CzeBsqSmTOLq_5UvL5s-0HDzaxw@mail.gmail.com","threadId":"66269","inReplyTo":"d09ef622-1398-4e38-8a04-8542e7347a98@gmail.com","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-07T16:36:40Z","receivedAt":"2026-09-07T16:36:53Z","isPatch":true,"body":"Hi Phillip,\n\nOn 07/09/2026 15:25, Phillip Wood wrote:\n>      The merge backend which is also used by \"git cherry-pick\" and \"git\n>      revert\" does not run it when it finishes.\n>\n> would be clearer to me\n\nYes, I'll use that.\n\n> Like Patrick I cannot understand what this is saying, let alone whether\n> it is saying anything useful.\n\nI've spelled it out in my reply to Patrick and will rewrite the\nmessage that way.\n\n>      Run \"git maintenace --auto\" at the end of all sequencer operations,\n>      ...\n>\n> would be clearer to me\n\nThat too.\n\n> Anyway this change is at the end of pick_commits(), just before we\n> finish so looks like the right place to call run_auto_maintenance()\n\nPatrick would rather have one exit shared by both rebase backends. In\nmy reply to him I've proposed moving the call out of the sequencer\ninto builtin/rebase.c and builtin/revert.c, the way am.c leaves it to\nrebase.c today. Say if you'd rather keep it here.\n\n> It is a shame the single pick variants of \"git cherry-pick\" and \"git\n> revert\" do not share the same code path as the multiple pick variants.\n> continue_single_pick() runs \"git commit\" without calling\n> run_git_commit() which is also unfortunate, but means that we could just\n> rely and \"git commit\" to call run_auto_maintenance() for us.\n\nThat works until the next patch, which turns auto maintenance off in\nevery command the sequencer spawns, this \"git commit\" included. So\nsomebody has to run it afterwards. With the call in builtin/revert.c,\ncherry-pick does that itself once the continue returns.\n\n> Do we want to assert that we don't run auto maintenance up to this point?\n\nYes, I'll add that, and the next patch will extend this test instead\nof adding its own.\n\n> Using test_grep here would mean we get some useful test output if there\n> are not matches in the file. Without that test_line_count just says the\n> line count didn't match and prints an empty file.\n\nWill do.\n\nThanks,\nThomas\n"},{"id":"552149","messageId":"CAA0xjtoUBHcEJA6_EGgiy2eXghb3duMpTi=KBkxt08fV0c5Arw@mail.gmail.com","threadId":"66269","inReplyTo":"7493f0b7-a6cb-4b7d-bfd4-f4a318ff7e32@gmail.com","subject":"Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-07T16:37:10Z","receivedAt":"2026-09-07T16:37:21Z","isPatch":true,"body":"Hi Phillip,\n\nOn 07/09/2026 15:24, Phillip Wood wrote:\n> I don't think maintenance is actively working against other commands, it\n> just creates lock contention. Maybe something like\n>\n>      When the sequencer runs \"git commit\" or \"git merge\", either directly\n>      or via a user supplied exec command, those commands run \"git\n>      maintenance --auto --detach\" which can cause lock contention with\n>      the sequencer.\n\nI'll use that. The repack case is a bit different, though. It can\ndelete a pack the sequencer still has open, which 65cda10d5b had to\nwork around, so I'll keep one sentence on it.\n\n> This is pretty hard to understand. What does 'the commit of one \"git\n> rebase --continue\"' mean? Also whether the next pick needs to take\n> MERGE_RR.lock is conditional on there being conflicts which isn't at all\n> clear.\n\nI meant the \"git commit\" that \"git rebase --continue\" spawns for a\nresolved conflict. Its maintenance run can still hold MERGE_RR.lock\nwhen the next pick conflicts and rerere needs it. I'll write it like\nthat.\n\n> What does that mean?\n\nOnce the spawned commands no longer run maintenance, a long sequence\ncan pile up loose objects, and nothing packs them before the run at\nthe end. I don't know whether a sequence can get long enough for that\nto matter. I'll say it like this, or drop it.\n\n> Talking about the shell here is unnecessarily confusing as the command\n> is not necessarily run by the shell: if it is a single word that does\n> not contain any shell metacharacters it is passed directly to exec()\n\nRight, the environment reaches the command either way. I'll drop the\nshell from the message.\n\n> This comment isn't wrong but sounds like an LLM, rather than something a\n> person would write.\n\nI've rewritten it:\n\n/*\n* Don't let the commands we spawn run auto maintenance. It would\n* race us for MERGE_RR.lock or delete packs we still have open,\n* so it runs once at the end of the sequence instead.\n*/\n\n> Shouldn't this just extend the test added in the previous patch, rather\n> than duplicating the coverage for auto maintenance being run at the end\n> of a rebase?\n\nYes, I'll extend both tests from the previous patch instead.\n\nThanks,\nThomas\n"},{"id":"552150","messageId":"CAA0xjtr9wKMuxTPwy+P_WpvJt1wocc4VzJ=O-C2Y_B3XuO_auw@mail.gmail.com","threadId":"66269","inReplyTo":"ap5yT0sOtLQQa4AY@pks.im","subject":"Re: [PATCH v2 1/3] config: add git_config_append_parameter()","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-07T16:37:26Z","receivedAt":"2026-09-07T16:37:38Z","isPatch":true,"body":"Hi Patrick,\n\nOn 07/09/2026 10:14, Patrick Steinhardt wrote:\n> Readers who don't have any context around GIT_CONFIG_PARAMETERS and what\n> it does will have a bit of a hard time making much sense of this, I\n> think. It usually helps to give a sentence or two explaining what the\n> infra even does, and what this quoting looks like.\n\nWill do. It is how \"git -c key=value\" reaches the child processes: a\nspace separated list of 'key'='value' pairs, each side single quoted,\nthat git_config_from_parameters() reads back. I'll say that in the\nmessage.\n\n> Pointing to that other function makes sense, but neither of the\n> functions documents the actual format that's used.\n\nI'll put the format in the header comment as well.\n\nThanks,\nThomas\n"},{"id":"552151","messageId":"1e9f7b72-9f77-46e9-950e-df60b5a0539f@gmail.com","threadId":"66269","inReplyTo":"CAA0xjto++XQ6SZVfr5hWq2+CzeBsqSmTOLq_5UvL5s-0HDzaxw@mail.gmail.com","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-07T16:40:12Z","receivedAt":"2026-09-07T16:40:17Z","isPatch":true,"body":"Hi Thomas\n\nOn 07/09/2026 17:36, Thomas Bachem wrote:\n> \n>> Anyway this change is at the end of pick_commits(), just before we\n>> finish so looks like the right place to call run_auto_maintenance()\n> \n> Patrick would rather have one exit shared by both rebase backends. In\n> my reply to him I've proposed moving the call out of the sequencer\n> into builtin/rebase.c and builtin/revert.c, the way am.c leaves it to\n> rebase.c today. Say if you'd rather keep it here.\n\nThat works for we and means we don't have to sprinkle calls to \nrun_auto_maintenance() around to accommodate the different code paths \nfor single and multiple picks.\n>> It is a shame the single pick variants of \"git cherry-pick\" and \"git\n>> revert\" do not share the same code path as the multiple pick variants.\n>> continue_single_pick() runs \"git commit\" without calling\n>> run_git_commit() which is also unfortunate, but means that we could just\n>> rely and \"git commit\" to call run_auto_maintenance() for us.\n> \n> That works until the next patch, which turns auto maintenance off in\n> every command the sequencer spawns, this \"git commit\" included. So\n> somebody has to run it afterwards. With the call in builtin/revert.c,\n> cherry-pick does that itself once the continue returns.\n\nSounds good\n\nThanks\n\nPhillip\n\n> \n>> Do we want to assert that we don't run auto maintenance up to this point?\n> \n> Yes, I'll add that, and the next patch will extend this test instead\n> of adding its own.\n> \n>> Using test_grep here would mean we get some useful test output if there\n>> are not matches in the file. Without that test_line_count just says the\n>> line count didn't match and prints an empty file.\n> \n> Will do.\n> \n> Thanks,\n> Thomas\n\n"},{"id":"552183","messageId":"ap-iEoeY7XKjeZgL@pks.im","threadId":"66269","inReplyTo":"CAA0xjtqy3jOPWAGL9Cr0B+VnHAkZF0=cVCxKNqMiVJpfbdpomA@mail.gmail.com","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-08T05:50:10Z","receivedAt":"2026-09-08T05:50:18Z","isPatch":true,"body":"On Mon, Sep 07, 2026 at 06:35:20PM +0200, Thomas Bachem wrote:\n> On 07/09/2026 10:14, Patrick Steinhardt wrote:\n[snip]\n> > It's surprisingly many sites where you add the call to\n> > `run_auto_maintenance()`. My hope was that there is a single exit path\n> > somewhere that is used by both the \"apply\" and \"merge\" strategy that we\n> > could adapt to unify when exactly we run auto-maintenance across both\n> > backends.\n> \n> There is none inside the sequencer. run_specific_rebase() calls\n> finish_rebase() for the apply backend only,\n> \"merge backend cleans up after itself\" as the comment there says.\n> Sequences end inside pick_commits(), and a single cherry-pick or\n> revert never creates sequencer state at all and returns straight to\n> builtin/revert.c. That is where the three sites come from.\n> \n> I could instead do what the apply backend already does. am.c skips\n> maintenance in rebasing mode and leaves it to rebase.c. If the\n> sequencer leaves it to its callers the same way, run_specific_rebase()\n> runs it for the merge backend too, once its state directory is gone,\n> and run_sequencer() in builtin/revert.c runs it for cherry-pick and\n> revert. Every entry into the merge backend returns through\n> run_specific_rebase(), --continue and --skip included, so nothing is\n> missed. The sequencer then never runs it, the change is in the two\n> builtins only, and the rule is short: the command runs it once when it\n> is done, and nothing it spawns does. Is that what you had in mind?\n\nMaybe. The question is what kind of impact it would have on other\nsubsystems. I think the most important part that I'm after is that the\ncommit message explains design decisions like this, as it gives the\nreader the required context to be able to evaluate the patch.\n\nAnd please stay mindful of LLM-generated commit messages. For most of\nthe part they are just completely useless as they tend to ramble without\nconveying any useful information. The commit message is the place where\nyou yourself sell the change to us, and by explaining the changes well\nyou demonstrate that you understand what you're sending to the mailing\nlist.\n\nAn LLM-generated commit message on the other side demonstrates nothing\nlike that. So in many cases, it's actively hurting your own mission as\npeople do notice that it's not generated by humans.\n\nIt's fine to use LLMs to help you with drafting the commit message. But\nwhat we're asking is that you double or even triple check what was\ngenerated and whether the generated message (1) makes sense and (2) is\nunderstandable by a normal human being.\n\nThanks!\n\nPatrick\n"},{"id":"552186","messageId":"CAA0xjtoQ_GjkG2FrhvNgGzaee4d7ypht9NpBSacw2fCO_=i=Sw@mail.gmail.com","threadId":"66269","inReplyTo":"ap-iEoeY7XKjeZgL@pks.im","subject":"Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-08T07:46:44Z","receivedAt":"2026-09-08T07:46:56Z","isPatch":true,"body":"Hi Patrick,\n\nOn 08/09/2026 07:50, Patrick Steinhardt wrote:\n> Maybe. The question is what kind of impact it would have on other\n> subsystems. I think the most important part that I'm after is that the\n> commit message explains design decisions like this, as it gives the\n> reader the required context to be able to evaluate the patch.\n\nNone that I can see. Outside sequencer.c the sequencer is only entered\nfrom builtin/rebase.c and builtin/revert.c, so those two are the only\nplaces the call moves to. I'll put that, and why, in the commit\nmessage.\n\n> It's fine to use LLMs to help you with drafting the commit message. But\n> what we're asking is that you double or even triple check what was\n> generated and whether the generated message (1) makes sense and (2) is\n> understandable by a normal human being.\n\nOkay, I'll rewrite all three messages for v3.\n\nThanks,\nThomas\n"},{"id":"552203","messageId":"pull.2217.v3.git.1788863286.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.git.1788508426.gitgitgadget@gmail.com","subject":"[PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-08T10:28:03Z","receivedAt":"2026-09-08T10:28:09Z","isPatch":true,"body":"Changes since v2:\n\n * Auto maintenance now runs from builtin/rebase.c and builtin/revert.c,\n   once the command is done, instead of from three places inside the\n   sequencer. That follows the apply backend, where \"git am\" leaves it to\n   rebase.c (Patrick, Phillip).\n * gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).\n * config_parameters is a char * built once with strbuf_detach() (Junio).\n * Patch 3 extends the tests of patch 2 instead of adding its own. They also\n   assert that nothing runs before a stop, and cover a single pick with\n   --edit and a sequence ending in --skip (Phillip).\n * Commit messages rewritten: what GIT_CONFIG_PARAMETERS is and looks like\n   (Patrick), what patch 2 changes for the user and why the call moved\n   (Patrick, Phillip), and the comment on the helper (Phillip).\n\nBased on master. Independent of the rerere lock fix in [1].\n\n[1] <pull.2214.v3.git.1788537081930.gitgitgadget@gmail.com>\n\nThomas Bachem (3):\n  config: add git_config_append_parameter()\n  rebase, cherry-pick, revert: run auto maintenance when done\n  sequencer: disable auto maintenance in spawned commands\n\n builtin/rebase.c                | 13 ++++++++---\n builtin/revert.c                | 19 +++++++++++------\n config.c                        | 20 +++++++++++------\n config.h                        | 13 +++++++++++\n sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 17 +++++++++++++++\n t/t3510-cherry-pick-sequence.sh | 31 +++++++++++++++++++++++++++\n 7 files changed, 131 insertions(+), 20 deletions(-)\n\n\nbase-commit: 3cb9185f65410273787f74333cc027d2ea5daada\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/2217\n\nRange-diff vs v2:\n\n 1:  ef8087e80d ! 1:  70db5ad084 config: add git_config_append_parameter()\n     @@ Metadata\n       ## Commit message ##\n          config: add git_config_append_parameter()\n      \n     -    Split the part of git_config_push_split_parameter() that formats one\n     -    GIT_CONFIG_PARAMETERS entry into a helper that appends it to a strbuf,\n     -    so that a caller can build a value for a child's environment without\n     -    knowing the quoting. The sequencer is about to do that.\n     +    \"git -c key=value\" passes its settings on to the git commands it\n     +    spawns through the environment variable GIT_CONFIG_PARAMETERS. The\n     +    value is a space separated list of 'key'='value' pairs with both\n     +    sides single quoted, which git_config_from_parameters() reads back in\n     +    the child. The only place we write such an entry is\n     +    git_config_push_split_parameter(), and it writes straight into our\n     +    own environment.\n     +\n     +    Split the formatting out into git_config_append_parameter(), which\n     +    appends one entry to a strbuf, so that we can build such a value for\n     +    a child's environment without repeating the quoting. The sequencer\n     +    will use it in a later commit to pass settings to the commands it\n     +    spawns.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n     @@ config.h: int git_config_from_blob_oid(config_fn_t fn, const char *name,\n       void git_config_push_env(const char *spec);\n      +\n      +/*\n     -+ * Append `key=value` to the GIT_CONFIG_PARAMETERS value in `env`, quoted\n     -+ * the way git_config_from_parameters() reads it, so that a child can be\n     -+ * given configuration on top of what this process was given. A NULL\n     -+ * `value` appends a boolean entry.\n     ++ * Append a \"-c key=value\" setting to a GIT_CONFIG_PARAMETERS value in\n     ++ * `env`. The variable carries such settings from a git process to the\n     ++ * git commands it spawns, as a space separated list of 'key'='value'\n     ++ * pairs with both sides single quoted, which git_config_from_parameters()\n     ++ * reads back. A NULL `value` appends 'key'= with nothing after the equals\n     ++ * sign, which stands for a boolean true, like \"-c key\" on the command\n     ++ * line.\n      + */\n      +void git_config_append_parameter(struct strbuf *env, const char *key,\n      +\t\t\t\t const char *value);\n 2:  baab8d4876 ! 2:  68a728c5f4 sequencer: run auto maintenance once a sequence is done\n     @@ Metadata\n      Author: Thomas Bachem <mail@thomasbachem.com>\n      \n       ## Commit message ##\n     -    sequencer: run auto maintenance once a sequence is done\n     +    rebase, cherry-pick, revert: run auto maintenance when done\n      \n     -    The apply backend of \"git rebase\" runs \"git maintenance run --auto\"\n     -    from finish_rebase() once it has applied its patches. The merge\n     -    backend, \"git cherry-pick\" and \"git revert\" do not run it when they\n     -    finish. They create their commits in process, and only the \"git\n     -    commit\" they spawn for an edited message or a resolved conflict, the\n     -    \"git merge\" a \"rebase -r\" spawns and an exec command start it, in the\n     -    middle of the sequence.\n     +    \"git commit\", \"git merge\", \"git fetch\" and \"git am\" run \"git\n     +    maintenance run --auto\" when they are done, and so does the apply\n     +    backend of \"git rebase\". That repacks the loose objects they wrote\n     +    once there are enough of them, expires old rerere entries and does\n     +    whatever other housekeeping is due.\n      \n     -    Run it where the sequencer finishes, so that every sequence ends the\n     -    way the apply backend does, and so that the next commit can keep it\n     -    out of the commands a sequence spawns.\n     +    The merge backend of \"git rebase\", \"git cherry-pick\" and \"git revert\"\n     +    do not. They create their commits in process, so auto maintenance\n     +    runs only when they spawn a command that runs it on its own. That is\n     +    the \"git commit\" for a resolved conflict or an edited message, the\n     +    \"git merge\" that \"--rebase-merges\" spawns for an octopus merge, a\n     +    strategy other than ort or any strategy option, and whatever an exec\n     +    runs. A sequence that needs none of these never runs auto\n     +    maintenance. One that stops for conflicts runs it after each\n     +    resolution, in the middle of the sequence.\n     +\n     +    Run it once when the sequence is done, like the apply backend does.\n     +\n     +    The apply backend leaves that to builtin/rebase.c: \"git am\" skips\n     +    auto maintenance in rebasing mode, and finish_rebase() runs it once\n     +    the patches are applied. Do the same for the sequencer, from\n     +    builtin/rebase.c and builtin/revert.c, because the sequencer itself\n     +    has no single place where every sequence ends. A sequence of several\n     +    commits ends inside pick_commits(). A single cherry-pick or revert\n     +    never creates the sequencer's state directory and returns to its\n     +    caller as soon as its commit is made. \"--continue\" and \"--skip\" have\n     +    entry points of their own. Nothing but those two builtins starts or\n     +    continues a sequence, so that is where we run auto maintenance.\n     +    run_specific_rebase() runs it for the merge backend once the\n     +    sequencer has returned successfully and removed its state directory,\n     +    which it keeps while the rebase is stopped. run_sequencer() runs it\n     +    for cherry-pick and revert when a pick, a \"--continue\" or a \"--skip\"\n     +    returns successfully.\n     +\n     +    For the user, a sequence that never stops now runs auto maintenance\n     +    once when it is done, where it never ran it before. That is the same\n     +    \"git maintenance run --auto --detach\" as after \"git commit\": it\n     +    detaches into the background by default and does nothing unless one\n     +    of its tasks is due. The runs from the commands a sequence spawns\n     +    stay for now. The next commit removes them, so that a sequence runs\n     +    auto maintenance exactly once.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n      \n     - ## sequencer.c ##\n     -@@ sequencer.c: cleanup_head_ref:\n     - \t\t\treturn -1;\n     - \t}\n     + ## builtin/rebase.c ##\n     +@@ builtin/rebase.c: static int run_specific_rebase(struct rebase_options *opts)\n       \n     -+\t/*\n     -+\t * We ignore errors in 'git maintenance run --auto', since the\n     -+\t * user should see them.\n     -+\t */\n     -+\trun_auto_maintenance(r, opts->quiet);\n     + \tif (opts->dont_finish_rebase)\n     + \t\t; /* do nothing */\n     +-\telse if (opts->type == REBASE_MERGE)\n     +-\t\t; /* merge backend cleans up after itself */\n     +-\telse if (status == 0) {\n     ++\telse if (opts->type == REBASE_MERGE) {\n     ++\t\tint quiet = !(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE));\n      +\n     - \t/*\n     - \t * Sequence of picks finished successfully; cleanup by\n     - \t * removing the .git/sequencer directory\n     -@@ sequencer.c: int sequencer_continue(struct repository *r, struct replay_opts *opts)\n     - \t\t\tres = -1;\n     - \t\t\tgoto release_todo_list;\n     - \t\t}\n     --\t} else if (!file_exists(get_todo_path(opts)))\n     --\t\treturn continue_single_pick(r, opts);\n     --\telse if ((res = read_populate_todo(r, &todo_list, opts)))\n     -+\t} else if (!file_exists(get_todo_path(opts))) {\n     -+\t\tres = continue_single_pick(r, opts);\n     -+\t\tif (!res)\n     -+\t\t\trun_auto_maintenance(r, opts->quiet);\n     -+\t\treturn res;\n     -+\t} else if ((res = read_populate_todo(r, &todo_list, opts))) {\n     - \t\tgoto release_todo_list;\n     -+\t}\n     ++\t\t/*\n     ++\t\t * The sequencer cleans up after itself. Its state directory\n     ++\t\t * is gone once it is done, and stays while it is stopped.\n     ++\t\t */\n     ++\t\tif (status == 0 && !is_directory(opts->state_dir))\n     ++\t\t\trun_auto_maintenance(the_repository, quiet);\n     ++\t} else if (status == 0) {\n     + \t\tif (!file_exists(state_dir_path(\"stopped-sha\", opts)))\n     + \t\t\tfinish_rebase(opts);\n     + \t} else if (status == 2) {\n     +\n     + ## builtin/revert.c ##\n     +@@\n     + #include \"gettext.h\"\n     + #include \"revision.h\"\n     + #include \"rerere.h\"\n     ++#include \"run-command.h\"\n     + #include \"sequencer.h\"\n     + #include \"branch.h\"\n       \n     - \tif (!is_rebase_i(opts)) {\n     - \t\t/* Verify that the conflict has been resolved */\n     -@@ sequencer.c: int sequencer_pick_revisions(struct repository *r,\n     - \t\t\tBUG(\"unexpected extra commit from walk\");\n     +@@ builtin/revert.c: static int run_sequencer(int argc, const char **argv, const char *prefix,\n     + \tconst char *strategy = &sentinel_value;\n     + \tconst char *gpg_sign = &sentinel_value;\n     + \tenum empty_action empty_opt = EMPTY_COMMIT_UNSPECIFIED;\n     +-\tint cmd = 0;\n     ++\tint cmd = 0, ret;\n     + \tstruct option base_options[] = {\n     + \t\tOPT_CMDMODE(0, \"quit\", &cmd, N_(\"end revert or cherry-pick sequence\"), 'q'),\n     + \t\tOPT_CMDMODE(0, \"continue\", &cmd, N_(\"resume revert or cherry-pick sequence\"), 'c'),\n     +@@ builtin/revert.c: static int run_sequencer(int argc, const char **argv, const char *prefix,\n     + \tfree(options);\n       \n     - \t\tres = single_pick(r, cmit, opts);\n     -+\t\tif (!res)\n     -+\t\t\trun_auto_maintenance(r, opts->quiet);\n     - \t\tgoto out;\n     + \tif (cmd == 'q') {\n     +-\t\tint ret = sequencer_remove_state(opts);\n     ++\t\tret = sequencer_remove_state(opts);\n     + \t\tif (!ret)\n     + \t\t\tremove_branch_state(the_repository, 0);\n     + \t\treturn ret;\n       \t}\n     +-\tif (cmd == 'c')\n     +-\t\treturn sequencer_continue(the_repository, opts);\n     + \tif (cmd == 'a')\n     + \t\treturn sequencer_rollback(the_repository, opts);\n     +-\tif (cmd == 's')\n     +-\t\treturn sequencer_skip(the_repository, opts);\n     +-\treturn sequencer_pick_revisions(the_repository, opts);\n     ++\tif (cmd == 'c')\n     ++\t\tret = sequencer_continue(the_repository, opts);\n     ++\telse if (cmd == 's')\n     ++\t\tret = sequencer_skip(the_repository, opts);\n     ++\telse\n     ++\t\tret = sequencer_pick_revisions(the_repository, opts);\n     ++\tif (!ret)\n     ++\t\trun_auto_maintenance(the_repository, opts->quiet);\n     ++\treturn ret;\n     + }\n       \n     + int cmd_revert(int argc,\n      \n       ## t/t3418-rebase-continue.sh ##\n      @@ t/t3418-rebase-continue.sh: test_orig_head () {\n       test_orig_head --apply\n       test_orig_head --merge\n       \n     -+test_expect_success 'rebase runs auto maintenance at its end' '\n     -+\tgit checkout -b one-exec main^ &&\n     -+\ttest_commit F4 &&\n     -+\ttest_must_fail git rebase -x false main &&\n     -+\tGIT_TRACE2_EVENT=\"$(pwd)/finish.txt\" git rebase --continue &&\n     -+\ttest_subcommand_flex git maintenance run --auto <finish.txt\n     ++test_expect_success 'rebase runs auto maintenance once it is done' '\n     ++\tgit checkout -b auto-maintenance topic &&\n     ++\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n     ++\t\tgit rebase -x false main &&\n     ++\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n     ++\techo resolved >F2 &&\n     ++\tgit add F2 &&\n     ++\ttest_must_fail git rebase --continue &&\n     ++\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n     ++\ttest_subcommand_flex git maintenance run --auto <end.txt\n      +'\n      +\n       test_done\n     @@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in ins\n      +\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n      +\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n      +\t\tgit cherry-pick anotherpick yetanotherpick &&\n     ++\ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n      +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n      +\ttest_line_count = 1 maintenance\n      +'\n     ++\n     ++test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '\n     ++\tpristine_detach initial &&\n     ++\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n     ++\t\tgit cherry-pick base..anotherpick &&\n     ++\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n     ++\techo resolved >foo &&\n     ++\tgit add foo &&\n     ++\ttest_must_fail git cherry-pick --continue &&\n     ++\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n     ++\ttest_subcommand_flex git maintenance run --auto <end.txt\n     ++'\n      +\n       test_done\n 3:  9a6fc0427a ! 3:  7a353df3d9 sequencer: keep auto maintenance out of the commands a sequence spawns\n     @@ Metadata\n      Author: Thomas Bachem <mail@thomasbachem.com>\n      \n       ## Commit message ##\n     -    sequencer: keep auto maintenance out of the commands a sequence spawns\n     +    sequencer: disable auto maintenance in spawned commands\n      \n     -    The \"git commit\" and \"git merge\" the sequencer spawns, and the git\n     -    commands an exec runs, each start \"git maintenance run --auto\n     -    --detach\", which then works in the background against the sequence\n     -    itself. A \"rerere gc\" started by the commit of one \"git rebase\n     -    --continue\" holds MERGE_RR.lock when the next pick needs it, and a\n     -    repack deletes packs the sequencer still has open, which 65cda10d5b\n     -    (sequencer: release the ODB before spawning git commit, 2026-08-12)\n     -    had to work around.\n     +    The \"git commit\" and \"git merge\" the sequencer spawns run \"git\n     +    maintenance run --auto --detach\" as they finish, and so does any\n     +    such command an exec runs. That maintenance then works in the\n     +    background while the sequencer goes on with the sequence, and the\n     +    two get in each other's way. With rerere enabled, the maintenance\n     +    started by the \"git commit\" of a \"git rebase --continue\" runs\n     +    \"rerere gc\", which can still hold MERGE_RR.lock when the next pick\n     +    conflicts. The rebase then dies with \"Unable to create\n     +    '.../MERGE_RR.lock': File exists\" instead of stopping for the user\n     +    to resolve the conflict. And a repack can delete a pack the\n     +    sequencer still has open, which 65cda10d5b (sequencer: release the\n     +    ODB before spawning git commit, 2026-08-12) works around.\n      \n     -    The loose objects a sequence creates wait for the run at its end that\n     -    the previous commit added. Whether a sequence can be long enough to\n     -    suffer from them before that remains to be seen. Pass\n     -    maintenance.auto=false and gc.auto=0 to the spawned commands through\n     -    GIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to\n     -    whatever it runs, appended after the user's own -c settings so that\n     -    ours win, and built once per run. A command the user runs while the\n     -    sequence is stopped, like \"git commit --amend\" at an edit, is not the\n     -    sequencer's to control and still runs maintenance.\n     +    Pass maintenance.auto=false to these commands through\n     +    GIT_CONFIG_PARAMETERS, as \"git -c\" would. We build the value once\n     +    from the one we inherited and append our setting after the user's\n     +    own -c settings so that it wins. The environment also reaches\n     +    everything the command spawns in turn, so a git command run from an\n     +    exec is covered as well. The sequencer also spawns \"git stash\", \"git\n     +    reset\" and \"git notes\", which never run auto maintenance.\n     +\n     +    With the previous commit, rebase, cherry-pick and revert run auto\n     +    maintenance once when they are done, so a sequence now runs it\n     +    exactly once, at the end. A sequence that stops for conflicts used\n     +    to run it at every resolution and now piles up its loose objects\n     +    until the end, as a sequence without conflicts always has.\n     +\n     +    A command the user runs while the sequence is stopped, like \"git\n     +    commit --amend\" at an edit, still runs auto maintenance. The\n     +    sequencer does not spawn it and has no say in it.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n     @@ sequencer.c: struct replay_ctx {\n       \t */\n       \tunsigned have_message :1;\n      +\t/*\n     -+\t * The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out\n     -+\t * of the commands we spawn, built on first use.\n     ++\t * GIT_CONFIG_PARAMETERS for the commands we spawn, with auto\n     ++\t * maintenance turned off. Built on first use.\n      +\t */\n     -+\tstruct strbuf config_parameters;\n     ++\tchar *config_parameters;\n       };\n       \n       struct replay_ctx* replay_ctx_new(void)\n     -@@ sequencer.c: struct replay_ctx* replay_ctx_new(void)\n     - \n     - \tstrbuf_init(&ctx->current_fixups, 0);\n     - \tstrbuf_init(&ctx->message, 0);\n     -+\tstrbuf_init(&ctx->config_parameters, 0);\n     - \n     - \treturn ctx;\n     - }\n      @@ sequencer.c: static void replay_ctx_release(struct replay_ctx *ctx)\n       {\n       \tstrbuf_release(&ctx->current_fixups);\n       \tstrbuf_release(&ctx->message);\n     -+\tstrbuf_release(&ctx->config_parameters);\n     ++\tfree(ctx->config_parameters);\n       }\n       \n       void replay_opts_release(struct replay_opts *opts)\n     @@ sequencer.c: static int run_command_silent_on_success(struct child_process *cmd)\n       }\n       \n      +/*\n     -+ * A sequence runs auto maintenance once it is done, not from every command\n     -+ * it spawns along the way: their background \"rerere gc\" or repack would\n     -+ * race the sequencer for locks and files it still holds.\n     ++ * Don't let the commands we spawn run auto maintenance. It would race\n     ++ * us for MERGE_RR.lock or delete packs we still have open. Our caller\n     ++ * runs it once the sequence is done.\n      + */\n      +static void disable_auto_maintenance(struct replay_opts *opts,\n      +\t\t\t\t     struct child_process *cmd)\n      +{\n     -+\tstruct strbuf *params = &opts->ctx->config_parameters;\n     -+\n     -+\tif (!params->len) {\n     ++\tif (!opts->ctx->config_parameters) {\n      +\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n     ++\t\tstruct strbuf buf = STRBUF_INIT;\n      +\n      +\t\tif (old && *old)\n     -+\t\t\tstrbuf_addstr(params, old);\n     -+\t\tgit_config_append_parameter(params, \"maintenance.auto\", \"false\");\n     -+\t\tgit_config_append_parameter(params, \"gc.auto\", \"0\");\n     ++\t\t\tstrbuf_addstr(&buf, old);\n     ++\t\tgit_config_append_parameter(&buf, \"maintenance.auto\", \"false\");\n     ++\t\topts->ctx->config_parameters = strbuf_detach(&buf, NULL);\n      +\t}\n     -+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT, params->buf);\n     ++\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT,\n     ++\t\t     opts->ctx->config_parameters);\n      +}\n      +\n       /*\n     @@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay\n       \t/*\n      \n       ## t/t3418-rebase-continue.sh ##\n     -@@ t/t3418-rebase-continue.sh: test_expect_success 'rebase runs auto maintenance at its end' '\n     - \ttest_subcommand_flex git maintenance run --auto <finish.txt\n     - '\n     - \n     -+test_expect_success 'rebase spawns no auto maintenance before its end' '\n     -+\tgit checkout -b two-conflicts topic &&\n     -+\ttest_commit F2-again F2 222 &&\n     -+\ttest_must_fail git rebase -x \"git commit --allow-empty -m exec\" main &&\n     -+\techo resolved >F2 &&\n     -+\tgit add F2 &&\n     +@@ t/t3418-rebase-continue.sh: test_orig_head --merge\n     + test_expect_success 'rebase runs auto maintenance once it is done' '\n     + \tgit checkout -b auto-maintenance topic &&\n     + \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n     +-\t\tgit rebase -x false main &&\n     ++\t\tgit rebase -x \"git commit --allow-empty -m exec && false\" main &&\n     + \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n     + \techo resolved >F2 &&\n     + \tgit add F2 &&\n     +-\ttest_must_fail git rebase --continue &&\n      +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n      +\t\tgit rebase --continue &&\n      +\ttest_subcommand_flex git commit <mid.txt &&\n      +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n     -+\techo resolved >F2 &&\n     -+\tgit add F2 &&\n     -+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n     + \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n     +-\ttest_subcommand_flex git maintenance run --auto <end.txt\n      +\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n      +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n      +\ttest_line_count = 1 maintenance\n     -+'\n     -+\n     + '\n     + \n       test_done\n      \n       ## t/t3510-cherry-pick-sequence.sh ##\n     -@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n     - \ttest_line_count = 1 maintenance\n     - '\n     - \n     -+test_expect_success 'cherry-pick spawns no auto maintenance before it is done' '\n     -+\tpristine_detach initial &&\n     -+\ttest_must_fail git cherry-pick base..anotherpick &&\n     -+\techo resolved >foo &&\n     -+\tgit add foo &&\n     +@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in insn sheet are optional' '\n     + \n     + test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n     + \tpristine_detach base &&\n     +-\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n     ++\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick --edit picked &&\n     ++\ttest_subcommand_flex git commit <single.txt &&\n     + \ttest_subcommand_flex git maintenance run --auto <single.txt &&\n     ++\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" single.txt >maintenance &&\n     ++\ttest_line_count = 1 maintenance &&\n     + \tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n     + \t\tgit cherry-pick anotherpick yetanotherpick &&\n     + \ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n     +@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i\n     + \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n     + \techo resolved >foo &&\n     + \tgit add foo &&\n     +-\ttest_must_fail git cherry-pick --continue &&\n      +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n      +\t\tgit cherry-pick --continue &&\n      +\ttest_subcommand_flex git commit <mid.txt &&\n      +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n     -+\techo d >foo &&\n     -+\tgit add foo &&\n     -+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --continue &&\n     -+\ttest_subcommand_flex git commit <end.txt &&\n     + \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n     +-\ttest_subcommand_flex git maintenance run --auto <end.txt\n     ++\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n      +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n      +\ttest_line_count = 1 maintenance\n     -+'\n     -+\n     + '\n     + \n       test_done\n\n-- \ngitgitgadget\n"},{"id":"552204","messageId":"70db5ad0841bb3db7538d709e0f1583aa70ae8bd.1788863286.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v3.git.1788863286.gitgitgadget@gmail.com","subject":"[PATCH v3 1/3] config: add git_config_append_parameter()","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-08T10:28:04Z","receivedAt":"2026-09-08T10:28:10Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\n\"git -c key=value\" passes its settings on to the git commands it\nspawns through the environment variable GIT_CONFIG_PARAMETERS. The\nvalue is a space separated list of 'key'='value' pairs with both\nsides single quoted, which git_config_from_parameters() reads back in\nthe child. The only place we write such an entry is\ngit_config_push_split_parameter(), and it writes straight into our\nown environment.\n\nSplit the formatting out into git_config_append_parameter(), which\nappends one entry to a strbuf, so that we can build such a value for\na child's environment without repeating the quoting. The sequencer\nwill use it in a later commit to pass settings to the commands it\nspawns.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n config.c | 20 +++++++++++++-------\n config.h | 13 +++++++++++++\n 2 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex d9019e7e6c..e0bb29b53d 100644\n--- a/config.c\n+++ b/config.c\n@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n \treturn ret;\n }\n \n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value)\n+{\n+\tif (env->len)\n+\t\tstrbuf_addch(env, ' ');\n+\tsq_quote_buf(env, key);\n+\tstrbuf_addch(env, '=');\n+\tif (value)\n+\t\tsq_quote_buf(env, value);\n+}\n+\n static void git_config_push_split_parameter(const char *key, const char *value)\n {\n \tstruct strbuf env = STRBUF_INIT;\n \tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n-\tif (old && *old) {\n+\tif (old && *old)\n \t\tstrbuf_addstr(&env, old);\n-\t\tstrbuf_addch(&env, ' ');\n-\t}\n-\tsq_quote_buf(&env, key);\n-\tstrbuf_addch(&env, '=');\n-\tif (value)\n-\t\tsq_quote_buf(&env, value);\n+\tgit_config_append_parameter(&env, key, value);\n \tsetenv(CONFIG_DATA_ENVIRONMENT, env.buf, 1);\n \tstrbuf_release(&env);\n }\ndiff --git a/config.h b/config.h\nindex b66dd08007..838d1509a9 100644\n--- a/config.h\n+++ b/config.h\n@@ -22,6 +22,7 @@\n  */\n \n struct object_id;\n+struct strbuf;\n \n /* git_config_parse_key() returns these negated: */\n #define CONFIG_INVALID_KEY 1\n@@ -186,6 +187,18 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name,\n \t\t\t     enum config_scope scope);\n void git_config_push_parameter(const char *text);\n void git_config_push_env(const char *spec);\n+\n+/*\n+ * Append a \"-c key=value\" setting to a GIT_CONFIG_PARAMETERS value in\n+ * `env`. The variable carries such settings from a git process to the\n+ * git commands it spawns, as a space separated list of 'key'='value'\n+ * pairs with both sides single quoted, which git_config_from_parameters()\n+ * reads back. A NULL `value` appends 'key'= with nothing after the equals\n+ * sign, which stands for a boolean true, like \"-c key\" on the command\n+ * line.\n+ */\n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value);\n int git_config_from_parameters(config_fn_t fn, void *data);\n \n /*\n-- \ngitgitgadget\n\n"},{"id":"552205","messageId":"68a728c5f43fdd7772a397954cd9f1a602614856.1788863286.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v3.git.1788863286.gitgitgadget@gmail.com","subject":"[PATCH v3 2/3] rebase, cherry-pick, revert: run auto maintenance when done","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-08T10:28:05Z","receivedAt":"2026-09-08T10:28:12Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\n\"git commit\", \"git merge\", \"git fetch\" and \"git am\" run \"git\nmaintenance run --auto\" when they are done, and so does the apply\nbackend of \"git rebase\". That repacks the loose objects they wrote\nonce there are enough of them, expires old rerere entries and does\nwhatever other housekeeping is due.\n\nThe merge backend of \"git rebase\", \"git cherry-pick\" and \"git revert\"\ndo not. They create their commits in process, so auto maintenance\nruns only when they spawn a command that runs it on its own. That is\nthe \"git commit\" for a resolved conflict or an edited message, the\n\"git merge\" that \"--rebase-merges\" spawns for an octopus merge, a\nstrategy other than ort or any strategy option, and whatever an exec\nruns. A sequence that needs none of these never runs auto\nmaintenance. One that stops for conflicts runs it after each\nresolution, in the middle of the sequence.\n\nRun it once when the sequence is done, like the apply backend does.\n\nThe apply backend leaves that to builtin/rebase.c: \"git am\" skips\nauto maintenance in rebasing mode, and finish_rebase() runs it once\nthe patches are applied. Do the same for the sequencer, from\nbuiltin/rebase.c and builtin/revert.c, because the sequencer itself\nhas no single place where every sequence ends. A sequence of several\ncommits ends inside pick_commits(). A single cherry-pick or revert\nnever creates the sequencer's state directory and returns to its\ncaller as soon as its commit is made. \"--continue\" and \"--skip\" have\nentry points of their own. Nothing but those two builtins starts or\ncontinues a sequence, so that is where we run auto maintenance.\nrun_specific_rebase() runs it for the merge backend once the\nsequencer has returned successfully and removed its state directory,\nwhich it keeps while the rebase is stopped. run_sequencer() runs it\nfor cherry-pick and revert when a pick, a \"--continue\" or a \"--skip\"\nreturns successfully.\n\nFor the user, a sequence that never stops now runs auto maintenance\nonce when it is done, where it never ran it before. That is the same\n\"git maintenance run --auto --detach\" as after \"git commit\": it\ndetaches into the background by default and does nothing unless one\nof its tasks is due. The runs from the commands a sequence spawns\nstay for now. The next commit removes them, so that a sequence runs\nauto maintenance exactly once.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n builtin/rebase.c                | 13 ++++++++++---\n builtin/revert.c                | 19 ++++++++++++-------\n t/t3418-rebase-continue.sh      | 12 ++++++++++++\n t/t3510-cherry-pick-sequence.sh | 23 +++++++++++++++++++++++\n 4 files changed, 57 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 10a306310c..535db60181 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -762,9 +762,16 @@ static int run_specific_rebase(struct rebase_options *opts)\n \n \tif (opts->dont_finish_rebase)\n \t\t; /* do nothing */\n-\telse if (opts->type == REBASE_MERGE)\n-\t\t; /* merge backend cleans up after itself */\n-\telse if (status == 0) {\n+\telse if (opts->type == REBASE_MERGE) {\n+\t\tint quiet = !(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE));\n+\n+\t\t/*\n+\t\t * The sequencer cleans up after itself. Its state directory\n+\t\t * is gone once it is done, and stays while it is stopped.\n+\t\t */\n+\t\tif (status == 0 && !is_directory(opts->state_dir))\n+\t\t\trun_auto_maintenance(the_repository, quiet);\n+\t} else if (status == 0) {\n \t\tif (!file_exists(state_dir_path(\"stopped-sha\", opts)))\n \t\t\tfinish_rebase(opts);\n \t} else if (status == 2) {\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex bedc40f368..52100a20cb 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -8,6 +8,7 @@\n #include \"gettext.h\"\n #include \"revision.h\"\n #include \"rerere.h\"\n+#include \"run-command.h\"\n #include \"sequencer.h\"\n #include \"branch.h\"\n \n@@ -116,7 +117,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,\n \tconst char *strategy = &sentinel_value;\n \tconst char *gpg_sign = &sentinel_value;\n \tenum empty_action empty_opt = EMPTY_COMMIT_UNSPECIFIED;\n-\tint cmd = 0;\n+\tint cmd = 0, ret;\n \tstruct option base_options[] = {\n \t\tOPT_CMDMODE(0, \"quit\", &cmd, N_(\"end revert or cherry-pick sequence\"), 'q'),\n \t\tOPT_CMDMODE(0, \"continue\", &cmd, N_(\"resume revert or cherry-pick sequence\"), 'c'),\n@@ -264,18 +265,22 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,\n \tfree(options);\n \n \tif (cmd == 'q') {\n-\t\tint ret = sequencer_remove_state(opts);\n+\t\tret = sequencer_remove_state(opts);\n \t\tif (!ret)\n \t\t\tremove_branch_state(the_repository, 0);\n \t\treturn ret;\n \t}\n-\tif (cmd == 'c')\n-\t\treturn sequencer_continue(the_repository, opts);\n \tif (cmd == 'a')\n \t\treturn sequencer_rollback(the_repository, opts);\n-\tif (cmd == 's')\n-\t\treturn sequencer_skip(the_repository, opts);\n-\treturn sequencer_pick_revisions(the_repository, opts);\n+\tif (cmd == 'c')\n+\t\tret = sequencer_continue(the_repository, opts);\n+\telse if (cmd == 's')\n+\t\tret = sequencer_skip(the_repository, opts);\n+\telse\n+\t\tret = sequencer_pick_revisions(the_repository, opts);\n+\tif (!ret)\n+\t\trun_auto_maintenance(the_repository, opts->quiet);\n+\treturn ret;\n }\n \n int cmd_revert(int argc,\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex cb5c3a1cb5..025787b5f2 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -395,4 +395,16 @@ test_orig_head () {\n test_orig_head --apply\n test_orig_head --merge\n \n+test_expect_success 'rebase runs auto maintenance once it is done' '\n+\tgit checkout -b auto-maintenance topic &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n+\t\tgit rebase -x false main &&\n+\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail git rebase --continue &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt\n+'\n+\n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 5777dff496..2bea55c3b6 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -721,4 +721,27 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \ttest_line_count = 4 commits\n '\n \n+test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n+\tpristine_detach base &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n+\t\tgit cherry-pick anotherpick yetanotherpick &&\n+\ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n+test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '\n+\tpristine_detach initial &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n+\t\tgit cherry-pick base..anotherpick &&\n+\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n+\techo resolved >foo &&\n+\tgit add foo &&\n+\ttest_must_fail git cherry-pick --continue &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"552206","messageId":"7a353df3d9d4b422b7df435a9f83c5b27d907ae4.1788863286.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v3.git.1788863286.gitgitgadget@gmail.com","subject":"[PATCH v3 3/3] sequencer: disable auto maintenance in spawned commands","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-08T10:28:06Z","receivedAt":"2026-09-08T10:28:14Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nThe \"git commit\" and \"git merge\" the sequencer spawns run \"git\nmaintenance run --auto --detach\" as they finish, and so does any\nsuch command an exec runs. That maintenance then works in the\nbackground while the sequencer goes on with the sequence, and the\ntwo get in each other's way. With rerere enabled, the maintenance\nstarted by the \"git commit\" of a \"git rebase --continue\" runs\n\"rerere gc\", which can still hold MERGE_RR.lock when the next pick\nconflicts. The rebase then dies with \"Unable to create\n'.../MERGE_RR.lock': File exists\" instead of stopping for the user\nto resolve the conflict. And a repack can delete a pack the\nsequencer still has open, which 65cda10d5b (sequencer: release the\nODB before spawning git commit, 2026-08-12) works around.\n\nPass maintenance.auto=false to these commands through\nGIT_CONFIG_PARAMETERS, as \"git -c\" would. We build the value once\nfrom the one we inherited and append our setting after the user's\nown -c settings so that it wins. The environment also reaches\neverything the command spawns in turn, so a git command run from an\nexec is covered as well. The sequencer also spawns \"git stash\", \"git\nreset\" and \"git notes\", which never run auto maintenance.\n\nWith the previous commit, rebase, cherry-pick and revert run auto\nmaintenance once when they are done, so a sequence now runs it\nexactly once, at the end. A sequence that stops for conflicts used\nto run it at every resolution and now piles up its loose objects\nuntil the end, as a sequence without conflicts always has.\n\nA command the user runs while the sequence is stopped, like \"git\ncommit --amend\" at an edit, still runs auto maintenance. The\nsequencer does not spawn it and has no say in it.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 11 +++++++---\n t/t3510-cherry-pick-sequence.sh | 14 +++++++++---\n 3 files changed, 54 insertions(+), 9 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 65afd100d9..e99ef09f02 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -234,6 +234,11 @@ struct replay_ctx {\n \t * Whether message contains a commit message.\n \t */\n \tunsigned have_message :1;\n+\t/*\n+\t * GIT_CONFIG_PARAMETERS for the commands we spawn, with auto\n+\t * maintenance turned off. Built on first use.\n+\t */\n+\tchar *config_parameters;\n };\n \n struct replay_ctx* replay_ctx_new(void)\n@@ -407,6 +412,7 @@ static void replay_ctx_release(struct replay_ctx *ctx)\n {\n \tstrbuf_release(&ctx->current_fixups);\n \tstrbuf_release(&ctx->message);\n+\tfree(ctx->config_parameters);\n }\n \n void replay_opts_release(struct replay_opts *opts)\n@@ -1107,6 +1113,27 @@ static int run_command_silent_on_success(struct child_process *cmd)\n \treturn rc;\n }\n \n+/*\n+ * Don't let the commands we spawn run auto maintenance. It would race\n+ * us for MERGE_RR.lock or delete packs we still have open. Our caller\n+ * runs it once the sequence is done.\n+ */\n+static void disable_auto_maintenance(struct replay_opts *opts,\n+\t\t\t\t     struct child_process *cmd)\n+{\n+\tif (!opts->ctx->config_parameters) {\n+\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n+\t\tif (old && *old)\n+\t\t\tstrbuf_addstr(&buf, old);\n+\t\tgit_config_append_parameter(&buf, \"maintenance.auto\", \"false\");\n+\t\topts->ctx->config_parameters = strbuf_detach(&buf, NULL);\n+\t}\n+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT,\n+\t\t     opts->ctx->config_parameters);\n+}\n+\n /*\n  * If we are cherry-pick, and if the merge did not result in\n  * hand-editing, we will hit this commit and inherit the original\n@@ -1148,6 +1175,7 @@ static int run_git_commit(const char *defmsg,\n \t\t\t     author_date_from_env(&cmd.env));\n \tif (opts->ignore_date)\n \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \n \tstrvec_push(&cmd.args, \"commit\");\n \n@@ -3924,16 +3952,18 @@ static int error_failed_squash(struct repository *r,\n \treturn error_with_patch(r, commit, subject, subject_len, opts, 1, 1);\n }\n \n-static int do_exec(struct repository *r, const char *command_line, int quiet)\n+static int do_exec(struct repository *r, const char *command_line,\n+\t\t   struct replay_opts *opts)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tint dirty, status;\n \n-\tif (!quiet)\n+\tif (!opts->quiet)\n \t\tfprintf(stderr, _(\"Executing: %s\\n\"), command_line);\n \tcmd.use_shell = 1;\n \tstrvec_push(&cmd.args, command_line);\n \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstatus = run_command(&cmd);\n \n \t/* force re-reading of the cache */\n@@ -4342,6 +4372,7 @@ static int do_merge(struct repository *r,\n \t\t\t\t     author_date_from_env(&cmd.env));\n \t\tif (opts->ignore_date)\n \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\t\tdisable_auto_maintenance(opts, &cmd);\n \n \t\tcmd.git_cmd = 1;\n \t\tstrvec_push(&cmd.args, \"merge\");\n@@ -5158,7 +5189,7 @@ static int pick_commits(struct repository *r,\n \t\t\tif (!opts->verbose)\n \t\t\t\tterm_clear_line();\n \t\t\t*end_of_arg = '\\0';\n-\t\t\tres = do_exec(r, arg, opts->quiet);\n+\t\t\tres = do_exec(r, arg, opts);\n \t\t\t*end_of_arg = saved;\n \n \t\t\tif (res) {\n@@ -5329,6 +5360,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \n \tcmd.git_cmd = 1;\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstrvec_push(&cmd.args, \"commit\");\n \n \t/*\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 025787b5f2..16def261b0 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -398,13 +398,18 @@ test_orig_head --merge\n test_expect_success 'rebase runs auto maintenance once it is done' '\n \tgit checkout -b auto-maintenance topic &&\n \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n-\t\tgit rebase -x false main &&\n+\t\tgit rebase -x \"git commit --allow-empty -m exec && false\" main &&\n \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n \techo resolved >F2 &&\n \tgit add F2 &&\n-\ttest_must_fail git rebase --continue &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit rebase --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n-\ttest_subcommand_flex git maintenance run --auto <end.txt\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n '\n \n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 2bea55c3b6..1e3fa1803c 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \n test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n \tpristine_detach base &&\n-\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick --edit picked &&\n+\ttest_subcommand_flex git commit <single.txt &&\n \ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" single.txt >maintenance &&\n+\ttest_line_count = 1 maintenance &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n \t\tgit cherry-pick anotherpick yetanotherpick &&\n \ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n@@ -739,9 +742,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i\n \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n \techo resolved >foo &&\n \tgit add foo &&\n-\ttest_must_fail git cherry-pick --continue &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit cherry-pick --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n-\ttest_subcommand_flex git maintenance run --auto <end.txt\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n '\n \n test_done\n-- \ngitgitgadget\n"},{"id":"552219","messageId":"xmqqse3jyc2m.fsf@gitster.g","threadId":"66269","inReplyTo":"pull.2217.v3.git.1788863286.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-08T15:53:05Z","receivedAt":"2026-09-08T15:53:09Z","isPatch":true,"body":"\"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Changes since v2:\n>\n>  * Auto maintenance now runs from builtin/rebase.c and builtin/revert.c,\n>    once the command is done, instead of from three places inside the\n>    sequencer. That follows the apply backend, where \"git am\" leaves it to\n>    rebase.c (Patrick, Phillip).\n>  * gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).\n>  * config_parameters is a char * built once with strbuf_detach() (Junio).\n>  * Patch 3 extends the tests of patch 2 instead of adding its own. They also\n>    assert that nothing runs before a stop, and cover a single pick with\n>    --edit and a sequence ending in --skip (Phillip).\n>  * Commit messages rewritten: what GIT_CONFIG_PARAMETERS is and looks like\n>    (Patrick), what patch 2 changes for the user and why the call moved\n>    (Patrick, Phillip), and the comment on the helper (Phillip).\n>\n> Based on master. Independent of the rerere lock fix in [1].\n\nWill queue.\n\nBy the way, is it just me or are proposed log messages getting\nlonger and longer with more irrelevant detaild these days?\n\nIf it is not just my imagination, this trend must stop.\n\nThrow \"Say the same thing in 1/N of the words used.\" followed by\nthese proposed log messages to your near-by LLM, see if the output\nstill makes sense, and adjust the value of N.\n\nFor example, I got the following from [3/3] with N==3 and I think\nthat is far easier to understand than the original.\n\n    Sequencer-spawned commands like 'commit' and 'merge' run\n    background auto maintenance, which interferes with ongoing\n    operations (e.g.  'rerere gc' holding MERGE_RR.lock or repacks\n    deleting active packs).\n\n    Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to all\n    spawned commands.  Building this value after user settings\n    ensures it wins and propagates to child processes.\n\n    Auto maintenance now runs exactly once when the sequence\n    completes.  Commands run manually by the user while stopped are\n    unaffected and continue to run auto maintenance normally.\n\nThanks.\n"},{"id":"552245","messageId":"48495cd8-c955-45c0-bcfd-ac32e4a11154@app.fastmail.com","threadId":"66269","inReplyTo":"xmqqse3jyc2m.fsf@gitster.g","subject":"Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-09-08T19:38:23Z","receivedAt":"2026-09-08T19:38:51Z","isPatch":true,"body":"On Tue, Sep 8, 2026, at 17:53, Junio C Hamano wrote:\n> \"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n>> Changes since v2:\n>>\n>>  * Auto maintenance now runs from builtin/rebase.c and builtin/revert.c,\n>>    once the command is done, instead of from three places inside the\n>>    sequencer. That follows the apply backend, where \"git am\" leaves it to\n>>    rebase.c (Patrick, Phillip).\n>>  * gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).\n>>  * config_parameters is a char * built once with strbuf_detach() (Junio).\n>>  * Patch 3 extends the tests of patch 2 instead of adding its own. They also\n>>    assert that nothing runs before a stop, and cover a single pick with\n>>    --edit and a sequence ending in --skip (Phillip).\n>>  * Commit messages rewritten: what GIT_CONFIG_PARAMETERS is and looks like\n>>    (Patrick), what patch 2 changes for the user and why the call moved\n>>    (Patrick, Phillip), and the comment on the helper (Phillip).\n>>\n>> Based on master. Independent of the rerere lock fix in [1].\n>\n> Will queue.\n>\n> By the way, is it just me or are proposed log messages getting\n> longer and longer with more irrelevant detaild these days?\n\n(sent from mobile)\n\nHere is my impression. Six months ago, an on the\nsurface thorough commit message would\n\n- describe the problem\n- describe the solution conceptually\n- maybe the concrete code solution...\n- maybe the alternatives not followed\n  through on...\n\n(and this is still the case overall)\n\nThat can lead to verbose commit messages.\nBut note. There were also many things *not*\nincluded.\n\n- What tests have been added, what they test\n- That the docs have been updated (accordingly)\n  and howso\n- Maybe even benchmarks when they are not\n  relevant?\n\nAnd only in the last six months have I seen\ncommit messages that look like they are \nexplicitly filling in an imagined form with\na dozen or so reminder/mandatory points.\n\n(Note in the cmt msg, not after it)\n\nThe most noticable ones to me are the ones\nwith the implied checkmarks in the last paragraph.\n\nThose old school commit messages took\nall the conventions and business as usual\n(like adding a regression test alongside\nthe bugfix) and didn't mention “and we are\nstill following the project guidelines by…”\n\nOf course, for those commit messages which look\nmore like code-to-English descriptions, I can't even\nkeep up and judge whether they are correct\nand coherent.\n\n>[snip]\n"},{"id":"552293","messageId":"aqD1ZlaLsJ7K04Bw@pks.im","threadId":"66269","inReplyTo":"xmqqse3jyc2m.fsf@gitster.g","subject":"Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-09T05:57:58Z","receivedAt":"2026-09-09T05:58:05Z","isPatch":true,"body":"On Tue, Sep 08, 2026 at 08:53:05AM -0700, Junio C Hamano wrote:\n> \"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n> > Changes since v2:\n> >\n> >  * Auto maintenance now runs from builtin/rebase.c and builtin/revert.c,\n> >    once the command is done, instead of from three places inside the\n> >    sequencer. That follows the apply backend, where \"git am\" leaves it to\n> >    rebase.c (Patrick, Phillip).\n> >  * gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).\n> >  * config_parameters is a char * built once with strbuf_detach() (Junio).\n> >  * Patch 3 extends the tests of patch 2 instead of adding its own. They also\n> >    assert that nothing runs before a stop, and cover a single pick with\n> >    --edit and a sequence ending in --skip (Phillip).\n> >  * Commit messages rewritten: what GIT_CONFIG_PARAMETERS is and looks like\n> >    (Patrick), what patch 2 changes for the user and why the call moved\n> >    (Patrick, Phillip), and the comment on the helper (Phillip).\n> >\n> > Based on master. Independent of the rerere lock fix in [1].\n> \n> Will queue.\n> \n> By the way, is it just me or are proposed log messages getting\n> longer and longer with more irrelevant detaild these days?\n> \n> If it is not just my imagination, this trend must stop.\n\nIt's not your imagination, it's gotten quite a bit worse over the last\ncouple weeks. I also started to push back on this trend, see [1] for\nexample.\n\nThanks!\n\nPatrick\n\n[1]: <ap-iEoeY7XKjeZgL@pks.im>\n"},{"id":"552302","messageId":"pull.2217.v4.git.1788942331.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.git.1788508426.gitgitgadget@gmail.com","subject":"[PATCH v4 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-09T08:25:28Z","receivedAt":"2026-09-09T08:25:34Z","isPatch":true,"body":"Changes since v3:\n\n * Commit messages condensed to about a third (Junio). 3/3 takes Junio's\n   wording, except that the setting goes to the commit, merge and exec\n   commands the sequencer spawns, not to all of them.\n\nNo code change.\n\nBased on master. Independent of the rerere lock fix in [1].\n\n[1] <pull.2214.v3.git.1788537081930.gitgitgadget@gmail.com>\n\nThomas Bachem (3):\n  config: add git_config_append_parameter()\n  rebase, cherry-pick, revert: run auto maintenance when done\n  sequencer: disable auto maintenance in spawned commands\n\n builtin/rebase.c                | 13 ++++++++---\n builtin/revert.c                | 19 +++++++++++------\n config.c                        | 20 +++++++++++------\n config.h                        | 13 +++++++++++\n sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 17 +++++++++++++++\n t/t3510-cherry-pick-sequence.sh | 31 +++++++++++++++++++++++++++\n 7 files changed, 131 insertions(+), 20 deletions(-)\n\n\nbase-commit: 3cb9185f65410273787f74333cc027d2ea5daada\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/2217\n\nRange-diff vs v3:\n\n 1:  70db5ad084 ! 1:  0472fadbc5 config: add git_config_append_parameter()\n     @@ Metadata\n       ## Commit message ##\n          config: add git_config_append_parameter()\n      \n     -    \"git -c key=value\" passes its settings on to the git commands it\n     -    spawns through the environment variable GIT_CONFIG_PARAMETERS. The\n     -    value is a space separated list of 'key'='value' pairs with both\n     -    sides single quoted, which git_config_from_parameters() reads back in\n     -    the child. The only place we write such an entry is\n     -    git_config_push_split_parameter(), and it writes straight into our\n     -    own environment.\n     +    \"git -c\" passes its settings to the commands it spawns through\n     +    GIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only\n     +    place that formats such an entry is git_config_push_split_parameter(),\n     +    which writes straight into our own environment.\n      \n          Split the formatting out into git_config_append_parameter(), which\n     -    appends one entry to a strbuf, so that we can build such a value for\n     -    a child's environment without repeating the quoting. The sequencer\n     -    will use it in a later commit to pass settings to the commands it\n     -    spawns.\n     +    appends one entry to a strbuf, so that a caller can build the value\n     +    for a child's environment. The sequencer will use it in a later\n     +    commit.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n 2:  68a728c5f4 ! 2:  b7b97262f2 rebase, cherry-pick, revert: run auto maintenance when done\n     @@ Metadata\n       ## Commit message ##\n          rebase, cherry-pick, revert: run auto maintenance when done\n      \n     -    \"git commit\", \"git merge\", \"git fetch\" and \"git am\" run \"git\n     -    maintenance run --auto\" when they are done, and so does the apply\n     -    backend of \"git rebase\". That repacks the loose objects they wrote\n     -    once there are enough of them, expires old rerere entries and does\n     -    whatever other housekeeping is due.\n     -\n     -    The merge backend of \"git rebase\", \"git cherry-pick\" and \"git revert\"\n     -    do not. They create their commits in process, so auto maintenance\n     -    runs only when they spawn a command that runs it on its own. That is\n     -    the \"git commit\" for a resolved conflict or an edited message, the\n     -    \"git merge\" that \"--rebase-merges\" spawns for an octopus merge, a\n     -    strategy other than ort or any strategy option, and whatever an exec\n     -    runs. A sequence that needs none of these never runs auto\n     -    maintenance. One that stops for conflicts runs it after each\n     -    resolution, in the middle of the sequence.\n     +    \"git cherry-pick\", \"git revert\" and the merge backend of \"git rebase\"\n     +    create their commits in process, so auto maintenance runs only when\n     +    they spawn a command that runs it, like the \"git commit\" for a\n     +    resolved conflict. A sequence thus runs it in the middle, after each\n     +    resolution, or never.\n      \n          Run it once when the sequence is done, like the apply backend does.\n      \n     -    The apply backend leaves that to builtin/rebase.c: \"git am\" skips\n     -    auto maintenance in rebasing mode, and finish_rebase() runs it once\n     -    the patches are applied. Do the same for the sequencer, from\n     -    builtin/rebase.c and builtin/revert.c, because the sequencer itself\n     -    has no single place where every sequence ends. A sequence of several\n     -    commits ends inside pick_commits(). A single cherry-pick or revert\n     -    never creates the sequencer's state directory and returns to its\n     -    caller as soon as its commit is made. \"--continue\" and \"--skip\" have\n     -    entry points of their own. Nothing but those two builtins starts or\n     -    continues a sequence, so that is where we run auto maintenance.\n     -    run_specific_rebase() runs it for the merge backend once the\n     -    sequencer has returned successfully and removed its state directory,\n     -    which it keeps while the rebase is stopped. run_sequencer() runs it\n     -    for cherry-pick and revert when a pick, a \"--continue\" or a \"--skip\"\n     -    returns successfully.\n     -\n     -    For the user, a sequence that never stops now runs auto maintenance\n     -    once when it is done, where it never ran it before. That is the same\n     -    \"git maintenance run --auto --detach\" as after \"git commit\": it\n     -    detaches into the background by default and does nothing unless one\n     -    of its tasks is due. The runs from the commands a sequence spawns\n     -    stay for now. The next commit removes them, so that a sequence runs\n     -    auto maintenance exactly once.\n     +    The sequencer has no single place where every sequence ends: a\n     +    sequence of several commits ends in pick_commits(), a single pick\n     +    returns as soon as its commit is made, and \"--continue\" and \"--skip\"\n     +    have entry points of their own. Run it from the two builtins that\n     +    start or continue a sequence instead: run_specific_rebase() once the\n     +    sequencer has returned and removed its state directory, and\n     +    run_sequencer() after a successful pick, \"--continue\" or \"--skip\".\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n 3:  7a353df3d9 ! 3:  031b3bd498 sequencer: disable auto maintenance in spawned commands\n     @@ Metadata\n       ## Commit message ##\n          sequencer: disable auto maintenance in spawned commands\n      \n     -    The \"git commit\" and \"git merge\" the sequencer spawns run \"git\n     -    maintenance run --auto --detach\" as they finish, and so does any\n     -    such command an exec runs. That maintenance then works in the\n     -    background while the sequencer goes on with the sequence, and the\n     -    two get in each other's way. With rerere enabled, the maintenance\n     -    started by the \"git commit\" of a \"git rebase --continue\" runs\n     -    \"rerere gc\", which can still hold MERGE_RR.lock when the next pick\n     -    conflicts. The rebase then dies with \"Unable to create\n     -    '.../MERGE_RR.lock': File exists\" instead of stopping for the user\n     -    to resolve the conflict. And a repack can delete a pack the\n     -    sequencer still has open, which 65cda10d5b (sequencer: release the\n     -    ODB before spawning git commit, 2026-08-12) works around.\n     +    Sequencer-spawned commands like 'commit' and 'merge' run\n     +    background auto maintenance, which interferes with ongoing\n     +    operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks\n     +    deleting active packs).\n      \n     -    Pass maintenance.auto=false to these commands through\n     -    GIT_CONFIG_PARAMETERS, as \"git -c\" would. We build the value once\n     -    from the one we inherited and append our setting after the user's\n     -    own -c settings so that it wins. The environment also reaches\n     -    everything the command spawns in turn, so a git command run from an\n     -    exec is covered as well. The sequencer also spawns \"git stash\", \"git\n     -    reset\" and \"git notes\", which never run auto maintenance.\n     +    Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the\n     +    spawned commit, merge and exec commands. Appending it after the\n     +    user's own settings ensures it wins, and the environment reaches\n     +    whatever they spawn in turn.\n      \n     -    With the previous commit, rebase, cherry-pick and revert run auto\n     -    maintenance once when they are done, so a sequence now runs it\n     -    exactly once, at the end. A sequence that stops for conflicts used\n     -    to run it at every resolution and now piles up its loose objects\n     -    until the end, as a sequence without conflicts always has.\n     -\n     -    A command the user runs while the sequence is stopped, like \"git\n     -    commit --amend\" at an edit, still runs auto maintenance. The\n     -    sequencer does not spawn it and has no say in it.\n     +    Auto maintenance now runs exactly once when the sequence\n     +    completes. Commands run manually by the user while stopped are\n     +    unaffected and continue to run auto maintenance normally.\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n\n-- \ngitgitgadget\n"},{"id":"552303","messageId":"0472fadbc564fb724e2cb14f306c1c29ed42ef40.1788942331.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v4.git.1788942331.gitgitgadget@gmail.com","subject":"[PATCH v4 1/3] config: add git_config_append_parameter()","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-09T08:25:29Z","receivedAt":"2026-09-09T08:25:36Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\n\"git -c\" passes its settings to the commands it spawns through\nGIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only\nplace that formats such an entry is git_config_push_split_parameter(),\nwhich writes straight into our own environment.\n\nSplit the formatting out into git_config_append_parameter(), which\nappends one entry to a strbuf, so that a caller can build the value\nfor a child's environment. The sequencer will use it in a later\ncommit.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n config.c | 20 +++++++++++++-------\n config.h | 13 +++++++++++++\n 2 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex d9019e7e6c..e0bb29b53d 100644\n--- a/config.c\n+++ b/config.c\n@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n \treturn ret;\n }\n \n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value)\n+{\n+\tif (env->len)\n+\t\tstrbuf_addch(env, ' ');\n+\tsq_quote_buf(env, key);\n+\tstrbuf_addch(env, '=');\n+\tif (value)\n+\t\tsq_quote_buf(env, value);\n+}\n+\n static void git_config_push_split_parameter(const char *key, const char *value)\n {\n \tstruct strbuf env = STRBUF_INIT;\n \tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n-\tif (old && *old) {\n+\tif (old && *old)\n \t\tstrbuf_addstr(&env, old);\n-\t\tstrbuf_addch(&env, ' ');\n-\t}\n-\tsq_quote_buf(&env, key);\n-\tstrbuf_addch(&env, '=');\n-\tif (value)\n-\t\tsq_quote_buf(&env, value);\n+\tgit_config_append_parameter(&env, key, value);\n \tsetenv(CONFIG_DATA_ENVIRONMENT, env.buf, 1);\n \tstrbuf_release(&env);\n }\ndiff --git a/config.h b/config.h\nindex b66dd08007..838d1509a9 100644\n--- a/config.h\n+++ b/config.h\n@@ -22,6 +22,7 @@\n  */\n \n struct object_id;\n+struct strbuf;\n \n /* git_config_parse_key() returns these negated: */\n #define CONFIG_INVALID_KEY 1\n@@ -186,6 +187,18 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name,\n \t\t\t     enum config_scope scope);\n void git_config_push_parameter(const char *text);\n void git_config_push_env(const char *spec);\n+\n+/*\n+ * Append a \"-c key=value\" setting to a GIT_CONFIG_PARAMETERS value in\n+ * `env`. The variable carries such settings from a git process to the\n+ * git commands it spawns, as a space separated list of 'key'='value'\n+ * pairs with both sides single quoted, which git_config_from_parameters()\n+ * reads back. A NULL `value` appends 'key'= with nothing after the equals\n+ * sign, which stands for a boolean true, like \"-c key\" on the command\n+ * line.\n+ */\n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value);\n int git_config_from_parameters(config_fn_t fn, void *data);\n \n /*\n-- \ngitgitgadget\n\n"},{"id":"552304","messageId":"b7b97262f27782f3271369115496c67f9774b8b2.1788942331.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v4.git.1788942331.gitgitgadget@gmail.com","subject":"[PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-09T08:25:30Z","receivedAt":"2026-09-09T08:25:37Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\n\"git cherry-pick\", \"git revert\" and the merge backend of \"git rebase\"\ncreate their commits in process, so auto maintenance runs only when\nthey spawn a command that runs it, like the \"git commit\" for a\nresolved conflict. A sequence thus runs it in the middle, after each\nresolution, or never.\n\nRun it once when the sequence is done, like the apply backend does.\n\nThe sequencer has no single place where every sequence ends: a\nsequence of several commits ends in pick_commits(), a single pick\nreturns as soon as its commit is made, and \"--continue\" and \"--skip\"\nhave entry points of their own. Run it from the two builtins that\nstart or continue a sequence instead: run_specific_rebase() once the\nsequencer has returned and removed its state directory, and\nrun_sequencer() after a successful pick, \"--continue\" or \"--skip\".\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n builtin/rebase.c                | 13 ++++++++++---\n builtin/revert.c                | 19 ++++++++++++-------\n t/t3418-rebase-continue.sh      | 12 ++++++++++++\n t/t3510-cherry-pick-sequence.sh | 23 +++++++++++++++++++++++\n 4 files changed, 57 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 10a306310c..535db60181 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -762,9 +762,16 @@ static int run_specific_rebase(struct rebase_options *opts)\n \n \tif (opts->dont_finish_rebase)\n \t\t; /* do nothing */\n-\telse if (opts->type == REBASE_MERGE)\n-\t\t; /* merge backend cleans up after itself */\n-\telse if (status == 0) {\n+\telse if (opts->type == REBASE_MERGE) {\n+\t\tint quiet = !(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE));\n+\n+\t\t/*\n+\t\t * The sequencer cleans up after itself. Its state directory\n+\t\t * is gone once it is done, and stays while it is stopped.\n+\t\t */\n+\t\tif (status == 0 && !is_directory(opts->state_dir))\n+\t\t\trun_auto_maintenance(the_repository, quiet);\n+\t} else if (status == 0) {\n \t\tif (!file_exists(state_dir_path(\"stopped-sha\", opts)))\n \t\t\tfinish_rebase(opts);\n \t} else if (status == 2) {\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex bedc40f368..52100a20cb 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -8,6 +8,7 @@\n #include \"gettext.h\"\n #include \"revision.h\"\n #include \"rerere.h\"\n+#include \"run-command.h\"\n #include \"sequencer.h\"\n #include \"branch.h\"\n \n@@ -116,7 +117,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,\n \tconst char *strategy = &sentinel_value;\n \tconst char *gpg_sign = &sentinel_value;\n \tenum empty_action empty_opt = EMPTY_COMMIT_UNSPECIFIED;\n-\tint cmd = 0;\n+\tint cmd = 0, ret;\n \tstruct option base_options[] = {\n \t\tOPT_CMDMODE(0, \"quit\", &cmd, N_(\"end revert or cherry-pick sequence\"), 'q'),\n \t\tOPT_CMDMODE(0, \"continue\", &cmd, N_(\"resume revert or cherry-pick sequence\"), 'c'),\n@@ -264,18 +265,22 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,\n \tfree(options);\n \n \tif (cmd == 'q') {\n-\t\tint ret = sequencer_remove_state(opts);\n+\t\tret = sequencer_remove_state(opts);\n \t\tif (!ret)\n \t\t\tremove_branch_state(the_repository, 0);\n \t\treturn ret;\n \t}\n-\tif (cmd == 'c')\n-\t\treturn sequencer_continue(the_repository, opts);\n \tif (cmd == 'a')\n \t\treturn sequencer_rollback(the_repository, opts);\n-\tif (cmd == 's')\n-\t\treturn sequencer_skip(the_repository, opts);\n-\treturn sequencer_pick_revisions(the_repository, opts);\n+\tif (cmd == 'c')\n+\t\tret = sequencer_continue(the_repository, opts);\n+\telse if (cmd == 's')\n+\t\tret = sequencer_skip(the_repository, opts);\n+\telse\n+\t\tret = sequencer_pick_revisions(the_repository, opts);\n+\tif (!ret)\n+\t\trun_auto_maintenance(the_repository, opts->quiet);\n+\treturn ret;\n }\n \n int cmd_revert(int argc,\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex cb5c3a1cb5..025787b5f2 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -395,4 +395,16 @@ test_orig_head () {\n test_orig_head --apply\n test_orig_head --merge\n \n+test_expect_success 'rebase runs auto maintenance once it is done' '\n+\tgit checkout -b auto-maintenance topic &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n+\t\tgit rebase -x false main &&\n+\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail git rebase --continue &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt\n+'\n+\n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 5777dff496..2bea55c3b6 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -721,4 +721,27 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \ttest_line_count = 4 commits\n '\n \n+test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n+\tpristine_detach base &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n+\t\tgit cherry-pick anotherpick yetanotherpick &&\n+\ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n+test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '\n+\tpristine_detach initial &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n+\t\tgit cherry-pick base..anotherpick &&\n+\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n+\techo resolved >foo &&\n+\tgit add foo &&\n+\ttest_must_fail git cherry-pick --continue &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"552305","messageId":"031b3bd498bd5efee7e0d9752a6dd36fe7a55360.1788942331.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v4.git.1788942331.gitgitgadget@gmail.com","subject":"[PATCH v4 3/3] sequencer: disable auto maintenance in spawned commands","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-09T08:25:31Z","receivedAt":"2026-09-09T08:25:39Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nSequencer-spawned commands like 'commit' and 'merge' run\nbackground auto maintenance, which interferes with ongoing\noperations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks\ndeleting active packs).\n\nPass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the\nspawned commit, merge and exec commands. Appending it after the\nuser's own settings ensures it wins, and the environment reaches\nwhatever they spawn in turn.\n\nAuto maintenance now runs exactly once when the sequence\ncompletes. Commands run manually by the user while stopped are\nunaffected and continue to run auto maintenance normally.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 11 +++++++---\n t/t3510-cherry-pick-sequence.sh | 14 +++++++++---\n 3 files changed, 54 insertions(+), 9 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 65afd100d9..e99ef09f02 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -234,6 +234,11 @@ struct replay_ctx {\n \t * Whether message contains a commit message.\n \t */\n \tunsigned have_message :1;\n+\t/*\n+\t * GIT_CONFIG_PARAMETERS for the commands we spawn, with auto\n+\t * maintenance turned off. Built on first use.\n+\t */\n+\tchar *config_parameters;\n };\n \n struct replay_ctx* replay_ctx_new(void)\n@@ -407,6 +412,7 @@ static void replay_ctx_release(struct replay_ctx *ctx)\n {\n \tstrbuf_release(&ctx->current_fixups);\n \tstrbuf_release(&ctx->message);\n+\tfree(ctx->config_parameters);\n }\n \n void replay_opts_release(struct replay_opts *opts)\n@@ -1107,6 +1113,27 @@ static int run_command_silent_on_success(struct child_process *cmd)\n \treturn rc;\n }\n \n+/*\n+ * Don't let the commands we spawn run auto maintenance. It would race\n+ * us for MERGE_RR.lock or delete packs we still have open. Our caller\n+ * runs it once the sequence is done.\n+ */\n+static void disable_auto_maintenance(struct replay_opts *opts,\n+\t\t\t\t     struct child_process *cmd)\n+{\n+\tif (!opts->ctx->config_parameters) {\n+\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n+\t\tif (old && *old)\n+\t\t\tstrbuf_addstr(&buf, old);\n+\t\tgit_config_append_parameter(&buf, \"maintenance.auto\", \"false\");\n+\t\topts->ctx->config_parameters = strbuf_detach(&buf, NULL);\n+\t}\n+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT,\n+\t\t     opts->ctx->config_parameters);\n+}\n+\n /*\n  * If we are cherry-pick, and if the merge did not result in\n  * hand-editing, we will hit this commit and inherit the original\n@@ -1148,6 +1175,7 @@ static int run_git_commit(const char *defmsg,\n \t\t\t     author_date_from_env(&cmd.env));\n \tif (opts->ignore_date)\n \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \n \tstrvec_push(&cmd.args, \"commit\");\n \n@@ -3924,16 +3952,18 @@ static int error_failed_squash(struct repository *r,\n \treturn error_with_patch(r, commit, subject, subject_len, opts, 1, 1);\n }\n \n-static int do_exec(struct repository *r, const char *command_line, int quiet)\n+static int do_exec(struct repository *r, const char *command_line,\n+\t\t   struct replay_opts *opts)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tint dirty, status;\n \n-\tif (!quiet)\n+\tif (!opts->quiet)\n \t\tfprintf(stderr, _(\"Executing: %s\\n\"), command_line);\n \tcmd.use_shell = 1;\n \tstrvec_push(&cmd.args, command_line);\n \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstatus = run_command(&cmd);\n \n \t/* force re-reading of the cache */\n@@ -4342,6 +4372,7 @@ static int do_merge(struct repository *r,\n \t\t\t\t     author_date_from_env(&cmd.env));\n \t\tif (opts->ignore_date)\n \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\t\tdisable_auto_maintenance(opts, &cmd);\n \n \t\tcmd.git_cmd = 1;\n \t\tstrvec_push(&cmd.args, \"merge\");\n@@ -5158,7 +5189,7 @@ static int pick_commits(struct repository *r,\n \t\t\tif (!opts->verbose)\n \t\t\t\tterm_clear_line();\n \t\t\t*end_of_arg = '\\0';\n-\t\t\tres = do_exec(r, arg, opts->quiet);\n+\t\t\tres = do_exec(r, arg, opts);\n \t\t\t*end_of_arg = saved;\n \n \t\t\tif (res) {\n@@ -5329,6 +5360,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \n \tcmd.git_cmd = 1;\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstrvec_push(&cmd.args, \"commit\");\n \n \t/*\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 025787b5f2..16def261b0 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -398,13 +398,18 @@ test_orig_head --merge\n test_expect_success 'rebase runs auto maintenance once it is done' '\n \tgit checkout -b auto-maintenance topic &&\n \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n-\t\tgit rebase -x false main &&\n+\t\tgit rebase -x \"git commit --allow-empty -m exec && false\" main &&\n \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n \techo resolved >F2 &&\n \tgit add F2 &&\n-\ttest_must_fail git rebase --continue &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit rebase --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n-\ttest_subcommand_flex git maintenance run --auto <end.txt\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n '\n \n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 2bea55c3b6..1e3fa1803c 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \n test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n \tpristine_detach base &&\n-\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick --edit picked &&\n+\ttest_subcommand_flex git commit <single.txt &&\n \ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" single.txt >maintenance &&\n+\ttest_line_count = 1 maintenance &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n \t\tgit cherry-pick anotherpick yetanotherpick &&\n \ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n@@ -739,9 +742,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i\n \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n \techo resolved >foo &&\n \tgit add foo &&\n-\ttest_must_fail git cherry-pick --continue &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit cherry-pick --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n-\ttest_subcommand_flex git maintenance run --auto <end.txt\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n '\n \n test_done\n-- \ngitgitgadget\n"},{"id":"552336","messageId":"cd3d98ef-ad80-405d-98b8-fc40e7c5ec9b@gmail.com","threadId":"66269","inReplyTo":"031b3bd498bd5efee7e0d9752a6dd36fe7a55360.1788942331.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 3/3] sequencer: disable auto maintenance in spawned commands","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-09T15:40:07Z","receivedAt":"2026-09-09T15:40:15Z","isPatch":true,"body":"Hi Thomas\n\nOn 09/09/2026 09:25, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> Sequencer-spawned commands like 'commit' and 'merge' run\n> background auto maintenance, which interferes with ongoing\n> operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks\n> deleting active packs).\n\nThis is much more concise, but still sounds a bit strange to me. I'd suggest\n\nWhen the sequencer spawns \"git commit\", or \"git merge\", those commands\nrun \"git maintenance --auto\" in the background which can interfere with\nthe sequencer (e.g. 'rerere gc' holding MERGE_RR.lock or repacks \ndeleting active packs).\n> Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the\n> spawned commit, merge and exec commands. Appending it after the\n> user's own settings ensures it wins, and the environment reaches\n> whatever they spawn in turn.\n> \n> Auto maintenance now runs exactly once when the sequence\n> completes. Commands run manually by the user while stopped are\n> unaffected and continue to run auto maintenance normally.\n\nGood, and the implementation changes look correct.\n\n> diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\n> index 025787b5f2..16def261b0 100755\n> --- a/t/t3418-rebase-continue.sh\n> +++ b/t/t3418-rebase-continue.sh\n> @@ -398,13 +398,18 @@ test_orig_head --merge\n>   test_expect_success 'rebase runs auto maintenance once it is done' '\n>   \tgit checkout -b auto-maintenance topic &&\n>   \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n> -\t\tgit rebase -x false main &&\n> +\t\tgit rebase -x \"git commit --allow-empty -m exec && false\" main &&\n>   \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n>   \techo resolved >F2 &&\n>   \tgit add F2 &&\n> -\ttest_must_fail git rebase --continue &&\n> +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n> +\t\tgit rebase --continue &&\n\nWhat's this trying to check - there wasn't a conflict so \ncommit_staged_changes() will error out without trying to commit \nanything. This series is looking pretty good now. Just to let you know \nI'll be off the list from tomorrow until the middle of next week so it \nwill be a few days before I look at any new versions of this patch.\n\nThanks\n\nPhillip\n\n> +\ttest_subcommand_flex git commit <mid.txt &&\n> +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n>   \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n> -\ttest_subcommand_flex git maintenance run --auto <end.txt\n> +\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n> +\ttest_line_count = 1 maintenance\n>   '\n>   \n>   test_done\n> diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\n> index 2bea55c3b6..1e3fa1803c 100755\n> --- a/t/t3510-cherry-pick-sequence.sh\n> +++ b/t/t3510-cherry-pick-sequence.sh\n> @@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n>   \n>   test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n>   \tpristine_detach base &&\n> -\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n> +\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick --edit picked &&\n> +\ttest_subcommand_flex git commit <single.txt &&\n>   \ttest_subcommand_flex git maintenance run --auto <single.txt &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" single.txt >maintenance &&\n> +\ttest_line_count = 1 maintenance &&\n>   \tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n>   \t\tgit cherry-pick anotherpick yetanotherpick &&\n>   \ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n> @@ -739,9 +742,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i\n>   \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n>   \techo resolved >foo &&\n>   \tgit add foo &&\n> -\ttest_must_fail git cherry-pick --continue &&\n> +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n> +\t\tgit cherry-pick --continue &&\n> +\ttest_subcommand_flex git commit <mid.txt &&\n> +\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n>   \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n> -\ttest_subcommand_flex git maintenance run --auto <end.txt\n> +\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n> +\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n> +\ttest_line_count = 1 maintenance\n>   '\n>   \n>   test_done\n\n"},{"id":"552419","messageId":"CAA0xjtrmi980617q0GPge3YpWmmpoaQOs8gTCfnJ2U0Hscw4Tg@mail.gmail.com","threadId":"66269","inReplyTo":"xmqqse3jyc2m.fsf@gitster.g","subject":"Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-10T08:25:06Z","receivedAt":"2026-09-10T08:25:20Z","isPatch":true,"body":"Hi Junio,\n\nOn 08/09/2026 17:53, Junio C Hamano wrote:\n> For example, I got the following from [3/3] with N==3 and I think\n> that is far easier to understand than the original.\n\nIt is. I took your text for 3/3 with one correction: it says the\nsetting goes to all spawned commands, but I only pass it to commit,\nmerge and exec. The sequencer also spawns stash, reset and notes, and\nthose never run auto maintenance.\n\nI shortened 1/3 and 2/3 to match and sent v4. The code is unchanged.\n\nThanks,\nThomas\n"},{"id":"552521","messageId":"aqOu-dvjAkkqx2Sr@pks.im","threadId":"66269","inReplyTo":"0472fadbc564fb724e2cb14f306c1c29ed42ef40.1788942331.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/3] config: add git_config_append_parameter()","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-11T07:34:17Z","receivedAt":"2026-09-11T07:34:31Z","isPatch":true,"body":"On Wed, Sep 09, 2026 at 08:25:29AM +0000, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> \"git -c\" passes its settings to the commands it spawns through\n> GIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only\n> place that formats such an entry is git_config_push_split_parameter(),\n> which writes straight into our own environment.\n> \n> Split the formatting out into git_config_append_parameter(), which\n> appends one entry to a strbuf, so that a caller can build the value\n> for a child's environment. The sequencer will use it in a later\n> commit.\n\nThanks, this commit message is much better now.\n\n> diff --git a/config.h b/config.h\n> index b66dd08007..838d1509a9 100644\n> --- a/config.h\n> +++ b/config.h\n> @@ -186,6 +187,18 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name,\n>  \t\t\t     enum config_scope scope);\n>  void git_config_push_parameter(const char *text);\n>  void git_config_push_env(const char *spec);\n> +\n> +/*\n> + * Append a \"-c key=value\" setting to a GIT_CONFIG_PARAMETERS value in\n> + * `env`. The variable carries such settings from a git process to the\n> + * git commands it spawns, as a space separated list of 'key'='value'\n> + * pairs with both sides single quoted, which git_config_from_parameters()\n> + * reads back. A NULL `value` appends 'key'= with nothing after the equals\n> + * sign, which stands for a boolean true, like \"-c key\" on the command\n> + * line.\n> + */\n\nNit: this is not necessarily specific to \"-c key=value\", and your later\npatches in fact add sites where that is not the source. Proposal:\n\n  Append a config option to the buffer that can be exported via the\n  GIT_CONFIG_PARAMETERS environment variable, which allows us to\n  propagate configuration across Git processes. The format of the\n  variable is a space-separated list of quoted \"'<key>'='<value>'\"\n  pairs.\n\nPatrick\n"},{"id":"552522","messageId":"aqOvAttPrhUIP_7U@pks.im","threadId":"66269","inReplyTo":"b7b97262f27782f3271369115496c67f9774b8b2.1788942331.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-11T07:34:26Z","receivedAt":"2026-09-11T07:34:34Z","isPatch":true,"body":"On Wed, Sep 09, 2026 at 08:25:30AM +0000, Thomas Bachem via GitGitGadget wrote:\n> From: Thomas Bachem <mail@thomasbachem.com>\n> \n> \"git cherry-pick\", \"git revert\" and the merge backend of \"git rebase\"\n> create their commits in process, so auto maintenance runs only when\n> they spawn a command that runs it, like the \"git commit\" for a\n> resolved conflict. A sequence thus runs it in the middle, after each\n> resolution, or never.\n\nThis paragraph still doesn't make a lot of sense. How about:\n\n  Commands that use the sequencer with the \"merge\" backend, like\n  git-cherry-pick(1) or git-rebase(1) with \"--merge\", create their\n  commits in-process. Consequently, these commands typically don't\n  execute auto-maintenance at all. The only exception is when a conflict\n  happens, as the user would have to manually commit the result via\n  git-commit(1), and that command triggers auto-maintenance for us.\n\n  In contrast to that, the \"apply\" backend of the sequencer _does_ run\n  auto-maintenance after it has processed the sequence of commits. And\n  this is a sensible thing to do: after all, we may just have written\n  lots of objects, so chances are high that we have something to clean\n  up now.\n\n  Adapt users of the \"merge\" backend to do the same.\n\n  Unfortunately, there is no single exit point for this backend where we\n  could add a call to `run_auto_maintenance()`. While one might expect\n  that we could simply trigger auto-maintenance in `pick_commits()` and\n  call it a day, a single pick as it is performed by e.g. git-revert(1)\n  never executes that function. So instead, manually trigger\n  auto-maintenance at several sites.\n\nThis last paragraph though...\n\n> Run it once when the sequence is done, like the apply backend does.\n> \n> The sequencer has no single place where every sequence ends: a\n> sequence of several commits ends in pick_commits(), a single pick\n> returns as soon as its commit is made, and \"--continue\" and \"--skip\"\n> have entry points of their own. Run it from the two builtins that\n> start or continue a sequence instead: run_specific_rebase() once the\n> sequencer has returned and removed its state directory, and\n> run_sequencer() after a successful pick, \"--continue\" or \"--skip\".\n\n... is still kind of dubious. As far as I can see, almost everything\ndoes end up in `pick_commits()` eventually:\n\n  - git-revert(1) does via `run_sequencer()`, which calls\n    `sequencer_pick_revisions()`, and that calls `pick_commits()`.\n\n  - git-cherry-pick(1) does via the same call chain.\n\n  - git-rebase(1) does so via `do_interactive_rebase()`, which calls\n    `complete_action()`, and that function calls `pick_commits()`. Or\n    alternatively via `sequencer_continue()`, which again calls it.\n\n  - Skipping commits via \"--skip\" eventually ends up in\n    `sequencer_continue()`, and that calls `pick_commits()`.\n\nThe only exception that I could spot is when we abort the sequencer. But\nI'd rather have us call auto-maintenance when `pick_commits()` is done\nand when we abort rather than having every user of the sequencer do it\nmanually.\n\nOr am I missing something here?\n\nPatrick\n"},{"id":"552671","messageId":"CAA0xjtr6FjdsfhfDbBW6OaxUqKpUo0prWE_SrLD_-0UBGfDAGQ@mail.gmail.com","threadId":"66269","inReplyTo":"cd3d98ef-ad80-405d-98b8-fc40e7c5ec9b@gmail.com","subject":"Re: [PATCH v4 3/3] sequencer: disable auto maintenance in spawned commands","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-14T07:11:51Z","receivedAt":"2026-09-14T07:12:05Z","isPatch":true,"body":"Hi Phillip,\n\nOn 09/09/2026 16:40, Phillip Wood wrote:\n> This is much more concise, but still sounds a bit strange to me. I'd suggest\n>\n> When the sequencer spawns \"git commit\", or \"git merge\", those commands\n> run \"git maintenance --auto\" in the background which can interfere with\n> the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock or repacks\n> deleting active packs).\n\nI'll take that.\n\n> What's this trying to check - there wasn't a conflict so\n> commit_staged_changes() will error out without trying to commit\n> anything.\n\nThere is one. In this script topic and main both add F2, so the pick\nconflicts and the rebase stops before it gets to the exec. The\n\"--continue\" then spawns \"git commit\" for the resolution, which is\nwhat I look for in mid.txt, and only then runs the exec, which fails\nand stops the rebase a second time. Without that line the check for\nno maintenance run right below it would also pass if nothing had been\nspawned at all. I'll add a comment to the test.\n\nThanks,\nThomas\n"},{"id":"552672","messageId":"CAA0xjtr+GiweJL7K0g=Wg0D=Surm906Q2Z==Jh8ROGnc1=TYPg@mail.gmail.com","threadId":"66269","inReplyTo":"aqOvAttPrhUIP_7U@pks.im","subject":"Re: [PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-14T07:12:04Z","receivedAt":"2026-09-14T07:12:16Z","isPatch":true,"body":"Hi Patrick,\n\nOn 11/09/2026 09:34, Patrick Steinhardt wrote:\n> Nit: this is not necessarily specific to \"-c key=value\", and your later\n> patches in fact add sites where that is not the source. Proposal:\n>\n>   Append a config option to the buffer that can be exported via the\n>   GIT_CONFIG_PARAMETERS environment variable, which allows us to\n>   propagate configuration across Git processes. The format of the\n>   variable is a space-separated list of quoted \"'<key>'='<value>'\"\n>   pairs.\n\nTaken. I'll keep one sentence after it on what a NULL value does,\nsince the function accepts one: it appends 'key'= with nothing after\nthe equals sign, which git reads back as true.\n\nThanks,\nThomas\n"},{"id":"552673","messageId":"CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com","threadId":"66269","inReplyTo":"aqOu-dvjAkkqx2Sr@pks.im","subject":"Re: [PATCH v4 1/3] config: add git_config_append_parameter()","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-14T07:12:43Z","receivedAt":"2026-09-14T07:13:00Z","isPatch":true,"body":"Hi Patrick,\n\nOn 11/09/2026 09:34, Patrick Steinhardt wrote:\n> This paragraph still doesn't make a lot of sense. How about:\n\nI'll take your text, with two corrections.\n\n>   execute auto-maintenance at all. The only exception is when a conflict\n>   happens, as the user would have to manually commit the result via\n>   git-commit(1), and that command triggers auto-maintenance for us.\n\nIt's the sequencer that spawns \"git commit\" there, on \"--continue\",\nand it spawns one for an edited message as well. That is why the next\npatch has to turn maintenance off in the spawned commands.\n\n>   In contrast to that, the \"apply\" backend of the sequencer _does_ run\n\nThe apply backend is \"git am\", driven from builtin/rebase.c, so I'll\nsay \"the apply backend of git rebase\".\n\n> ... is still kind of dubious. As far as I can see, almost everything\n> does end up in `pick_commits()` eventually:\n[...]\n> The only exception that I could spot is when we abort the sequencer. But\n> I'd rather have us call auto-maintenance when `pick_commits()` is done\n> and when we abort rather than having every user of the sequencer do it\n> manually.\n>\n> Or am I missing something here?\n\nThe single picks. \"git cherry-pick <commit>\" and \"git revert <commit>\"\ntake the single_pick() branch at the top of sequencer_pick_revisions()\nand return from there. Their \"--continue\" returns from\nsequencer_continue() through continue_single_pick() when there is no\ntodo file, and their \"--skip\" returns from sequencer_skip() right\nafter skip_single_pick(). None of them gets to pick_commits(). For\nrebase you're right, complete_action() and sequencer_continue() both\nend up there.\n\nSo inside the sequencer the call would go to the end of pick_commits()\nand to those three returns, plus the aborts if you want them there.\n\"git rebase --abort\" already runs it from finish_rebase(), so that\nwould be cherry-pick and revert only. The two builtins are the\nsequencer's only callers, which is why I moved it to them, and Phillip\npreferred that too, for the single pick paths. Both work for me, say\nwhich and I'll reroll. I'll name the functions above in the message\nwhichever you pick.\n\nThanks,\nThomas\n"},{"id":"552828","messageId":"pull.2217.v5.git.1789670534.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.git.1788508426.gitgitgadget@gmail.com","subject":"[PATCH v5 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-17T18:42:11Z","receivedAt":"2026-09-17T18:42:16Z","isPatch":true,"body":"Changes since v4:\n\n * 2/3 takes Patrick's wording, with two corrections: the sequencer itself\n   spawns the \"git commit\" for a resolved conflict, and the apply backend\n   belongs to \"git rebase\", not to the sequencer.\n * 3/3 opens with Phillip's sentence.\n * The header comment of git_config_append_parameter() is Patrick's, plus\n   one sentence on a NULL value.\n * Both tests got a comment on which picks conflict and where the sequence\n   stops (Phillip).\n\nThe code is unchanged.\n\nPatrick, my answer to your question on 2/3 went out under the 1/3 subject by\nmistake [1]. The single picks are another exception: a \"git cherry-pick\n<commit>\" or \"git revert <commit>\" never reaches pick_commits(), and neither\ndoes its \"--continue\" or \"--skip\". So inside the sequencer the call would go\nto the end of pick_commits() and to those three places, plus the aborts if\nyou want them. I kept it in the two builtins, which Phillip preferred, and\n2/3 now says why. Say if you'd rather have it in the sequencer and I'll move\nit.\n\nBased on master. Independent of the rerere series in [2].\n\n[1] <CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com>\n\n[2] <pull.2214.v4.git.1789373061.gitgitgadget@gmail.com>\n\nThomas Bachem (3):\n  config: add git_config_append_parameter()\n  rebase, cherry-pick, revert: run auto maintenance when done\n  sequencer: disable auto maintenance in spawned commands\n\n builtin/rebase.c                | 13 ++++++++---\n builtin/revert.c                | 19 +++++++++++------\n config.c                        | 20 +++++++++++------\n config.h                        | 12 +++++++++++\n sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 20 +++++++++++++++++\n t/t3510-cherry-pick-sequence.sh | 33 ++++++++++++++++++++++++++++\n 7 files changed, 135 insertions(+), 20 deletions(-)\n\n\nbase-commit: 3cb9185f65410273787f74333cc027d2ea5daada\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v5\nPull-Request: https://github.com/gitgitgadget/git/pull/2217\n\nRange-diff vs v4:\n\n 1:  0472fadbc5 ! 1:  724baf2789 config: add git_config_append_parameter()\n     @@ config.h: int git_config_from_blob_oid(config_fn_t fn, const char *name,\n       void git_config_push_env(const char *spec);\n      +\n      +/*\n     -+ * Append a \"-c key=value\" setting to a GIT_CONFIG_PARAMETERS value in\n     -+ * `env`. The variable carries such settings from a git process to the\n     -+ * git commands it spawns, as a space separated list of 'key'='value'\n     -+ * pairs with both sides single quoted, which git_config_from_parameters()\n     -+ * reads back. A NULL `value` appends 'key'= with nothing after the equals\n     -+ * sign, which stands for a boolean true, like \"-c key\" on the command\n     -+ * line.\n     ++ * Append a config option to the buffer that can be exported via the\n     ++ * GIT_CONFIG_PARAMETERS environment variable, which allows us to\n     ++ * propagate configuration across Git processes. The format of the\n     ++ * variable is a space-separated list of quoted \"'<key>'='<value>'\"\n     ++ * pairs. With a NULL `value`, only 'key'= is appended, which git reads\n     ++ * back as a boolean true, like \"-c key\" on the command line.\n      + */\n      +void git_config_append_parameter(struct strbuf *env, const char *key,\n      +\t\t\t\t const char *value);\n 2:  b7b97262f2 ! 2:  f0ec8f1f41 rebase, cherry-pick, revert: run auto maintenance when done\n     @@ Metadata\n       ## Commit message ##\n          rebase, cherry-pick, revert: run auto maintenance when done\n      \n     -    \"git cherry-pick\", \"git revert\" and the merge backend of \"git rebase\"\n     -    create their commits in process, so auto maintenance runs only when\n     -    they spawn a command that runs it, like the \"git commit\" for a\n     -    resolved conflict. A sequence thus runs it in the middle, after each\n     -    resolution, or never.\n     +    Commands that use the sequencer with the \"merge\" backend, like\n     +    git-cherry-pick(1) or git-rebase(1) with \"--merge\", create their\n     +    commits in-process. Consequently, these commands typically don't\n     +    execute auto maintenance at all. Only the commands they spawn on the\n     +    way run it, like git-commit(1) for a resolved conflict or an edited\n     +    message.\n      \n     -    Run it once when the sequence is done, like the apply backend does.\n     +    In contrast to that, the \"apply\" backend of git-rebase(1) _does_ run\n     +    auto maintenance after it has processed the sequence of commits. And\n     +    this is a sensible thing to do: after all, we may just have written\n     +    lots of objects, so chances are high that we have something to clean\n     +    up now.\n      \n     -    The sequencer has no single place where every sequence ends: a\n     -    sequence of several commits ends in pick_commits(), a single pick\n     -    returns as soon as its commit is made, and \"--continue\" and \"--skip\"\n     -    have entry points of their own. Run it from the two builtins that\n     -    start or continue a sequence instead: run_specific_rebase() once the\n     -    sequencer has returned and removed its state directory, and\n     -    run_sequencer() after a successful pick, \"--continue\" or \"--skip\".\n     +    Adapt users of the \"merge\" backend to do the same.\n     +\n     +    The sequencer has no single exit where a call to run_auto_maintenance()\n     +    could go. A sequence ends in pick_commits(), but a single pick never\n     +    gets there: it returns from sequencer_pick_revisions() via\n     +    single_pick(), its \"--continue\" from sequencer_continue() via\n     +    continue_single_pick(), and its \"--skip\" from sequencer_skip(). So\n     +    call it from the sequencer's two callers instead: run_specific_rebase()\n     +    for the merge backend, once its state directory is gone, and\n     +    run_sequencer() in builtin/revert.c after a successful pick,\n     +    \"--continue\" or \"--skip\".\n      \n          Assisted-by: Claude Fable 5.1\n          Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n     @@ t/t3418-rebase-continue.sh: test_orig_head () {\n       test_orig_head --merge\n       \n      +test_expect_success 'rebase runs auto maintenance once it is done' '\n     ++\t# topic and main both add F2, so the pick conflicts and the rebase\n     ++\t# stops before the exec runs, and once more when the exec fails\n      +\tgit checkout -b auto-maintenance topic &&\n      +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n      +\t\tgit rebase -x false main &&\n     @@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in ins\n      +'\n      +\n      +test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '\n     ++\t# both picked and anotherpick conflict on foo, so \"--continue\" stops\n     ++\t# once more before \"--skip\" ends the sequence\n      +\tpristine_detach initial &&\n      +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n      +\t\tgit cherry-pick base..anotherpick &&\n 3:  031b3bd498 ! 3:  c51ea031ea sequencer: disable auto maintenance in spawned commands\n     @@ Metadata\n       ## Commit message ##\n          sequencer: disable auto maintenance in spawned commands\n      \n     -    Sequencer-spawned commands like 'commit' and 'merge' run\n     -    background auto maintenance, which interferes with ongoing\n     -    operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks\n     -    deleting active packs).\n     +    When the sequencer spawns \"git commit\" or \"git merge\", those commands\n     +    run \"git maintenance run --auto\" in the background, which can\n     +    interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock\n     +    or repacks deleting active packs).\n      \n          Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the\n          spawned commit, merge and exec commands. Appending it after the\n     @@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay\n      \n       ## t/t3418-rebase-continue.sh ##\n      @@ t/t3418-rebase-continue.sh: test_orig_head --merge\n     + \n       test_expect_success 'rebase runs auto maintenance once it is done' '\n     + \t# topic and main both add F2, so the pick conflicts and the rebase\n     +-\t# stops before the exec runs, and once more when the exec fails\n     ++\t# stops before the exec runs. \"--continue\" commits the resolution\n     ++\t# first, then runs the exec, which fails and stops it again.\n       \tgit checkout -b auto-maintenance topic &&\n       \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n      -\t\tgit rebase -x false main &&\n\n-- \ngitgitgadget\n"},{"id":"552829","messageId":"724baf2789f77477101bc909b243c67981d78eac.1789670534.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v5.git.1789670534.gitgitgadget@gmail.com","subject":"[PATCH v5 1/3] config: add git_config_append_parameter()","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-17T18:42:12Z","receivedAt":"2026-09-17T18:42:17Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\n\"git -c\" passes its settings to the commands it spawns through\nGIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only\nplace that formats such an entry is git_config_push_split_parameter(),\nwhich writes straight into our own environment.\n\nSplit the formatting out into git_config_append_parameter(), which\nappends one entry to a strbuf, so that a caller can build the value\nfor a child's environment. The sequencer will use it in a later\ncommit.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n config.c | 20 +++++++++++++-------\n config.h | 12 ++++++++++++\n 2 files changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex d9019e7e6c..e0bb29b53d 100644\n--- a/config.c\n+++ b/config.c\n@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,\n \treturn ret;\n }\n \n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value)\n+{\n+\tif (env->len)\n+\t\tstrbuf_addch(env, ' ');\n+\tsq_quote_buf(env, key);\n+\tstrbuf_addch(env, '=');\n+\tif (value)\n+\t\tsq_quote_buf(env, value);\n+}\n+\n static void git_config_push_split_parameter(const char *key, const char *value)\n {\n \tstruct strbuf env = STRBUF_INIT;\n \tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n-\tif (old && *old) {\n+\tif (old && *old)\n \t\tstrbuf_addstr(&env, old);\n-\t\tstrbuf_addch(&env, ' ');\n-\t}\n-\tsq_quote_buf(&env, key);\n-\tstrbuf_addch(&env, '=');\n-\tif (value)\n-\t\tsq_quote_buf(&env, value);\n+\tgit_config_append_parameter(&env, key, value);\n \tsetenv(CONFIG_DATA_ENVIRONMENT, env.buf, 1);\n \tstrbuf_release(&env);\n }\ndiff --git a/config.h b/config.h\nindex b66dd08007..b048f63571 100644\n--- a/config.h\n+++ b/config.h\n@@ -22,6 +22,7 @@\n  */\n \n struct object_id;\n+struct strbuf;\n \n /* git_config_parse_key() returns these negated: */\n #define CONFIG_INVALID_KEY 1\n@@ -186,6 +187,17 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name,\n \t\t\t     enum config_scope scope);\n void git_config_push_parameter(const char *text);\n void git_config_push_env(const char *spec);\n+\n+/*\n+ * Append a config option to the buffer that can be exported via the\n+ * GIT_CONFIG_PARAMETERS environment variable, which allows us to\n+ * propagate configuration across Git processes. The format of the\n+ * variable is a space-separated list of quoted \"'<key>'='<value>'\"\n+ * pairs. With a NULL `value`, only 'key'= is appended, which git reads\n+ * back as a boolean true, like \"-c key\" on the command line.\n+ */\n+void git_config_append_parameter(struct strbuf *env, const char *key,\n+\t\t\t\t const char *value);\n int git_config_from_parameters(config_fn_t fn, void *data);\n \n /*\n-- \ngitgitgadget\n\n"},{"id":"552830","messageId":"f0ec8f1f41dc2c516193dc99cc2e70c3cba25bea.1789670534.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v5.git.1789670534.gitgitgadget@gmail.com","subject":"[PATCH v5 2/3] rebase, cherry-pick, revert: run auto maintenance when done","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-17T18:42:13Z","receivedAt":"2026-09-17T18:42:18Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nCommands that use the sequencer with the \"merge\" backend, like\ngit-cherry-pick(1) or git-rebase(1) with \"--merge\", create their\ncommits in-process. Consequently, these commands typically don't\nexecute auto maintenance at all. Only the commands they spawn on the\nway run it, like git-commit(1) for a resolved conflict or an edited\nmessage.\n\nIn contrast to that, the \"apply\" backend of git-rebase(1) _does_ run\nauto maintenance after it has processed the sequence of commits. And\nthis is a sensible thing to do: after all, we may just have written\nlots of objects, so chances are high that we have something to clean\nup now.\n\nAdapt users of the \"merge\" backend to do the same.\n\nThe sequencer has no single exit where a call to run_auto_maintenance()\ncould go. A sequence ends in pick_commits(), but a single pick never\ngets there: it returns from sequencer_pick_revisions() via\nsingle_pick(), its \"--continue\" from sequencer_continue() via\ncontinue_single_pick(), and its \"--skip\" from sequencer_skip(). So\ncall it from the sequencer's two callers instead: run_specific_rebase()\nfor the merge backend, once its state directory is gone, and\nrun_sequencer() in builtin/revert.c after a successful pick,\n\"--continue\" or \"--skip\".\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n builtin/rebase.c                | 13 ++++++++++---\n builtin/revert.c                | 19 ++++++++++++-------\n t/t3418-rebase-continue.sh      | 14 ++++++++++++++\n t/t3510-cherry-pick-sequence.sh | 25 +++++++++++++++++++++++++\n 4 files changed, 61 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 10a306310c..535db60181 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -762,9 +762,16 @@ static int run_specific_rebase(struct rebase_options *opts)\n \n \tif (opts->dont_finish_rebase)\n \t\t; /* do nothing */\n-\telse if (opts->type == REBASE_MERGE)\n-\t\t; /* merge backend cleans up after itself */\n-\telse if (status == 0) {\n+\telse if (opts->type == REBASE_MERGE) {\n+\t\tint quiet = !(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE));\n+\n+\t\t/*\n+\t\t * The sequencer cleans up after itself. Its state directory\n+\t\t * is gone once it is done, and stays while it is stopped.\n+\t\t */\n+\t\tif (status == 0 && !is_directory(opts->state_dir))\n+\t\t\trun_auto_maintenance(the_repository, quiet);\n+\t} else if (status == 0) {\n \t\tif (!file_exists(state_dir_path(\"stopped-sha\", opts)))\n \t\t\tfinish_rebase(opts);\n \t} else if (status == 2) {\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex bedc40f368..52100a20cb 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -8,6 +8,7 @@\n #include \"gettext.h\"\n #include \"revision.h\"\n #include \"rerere.h\"\n+#include \"run-command.h\"\n #include \"sequencer.h\"\n #include \"branch.h\"\n \n@@ -116,7 +117,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,\n \tconst char *strategy = &sentinel_value;\n \tconst char *gpg_sign = &sentinel_value;\n \tenum empty_action empty_opt = EMPTY_COMMIT_UNSPECIFIED;\n-\tint cmd = 0;\n+\tint cmd = 0, ret;\n \tstruct option base_options[] = {\n \t\tOPT_CMDMODE(0, \"quit\", &cmd, N_(\"end revert or cherry-pick sequence\"), 'q'),\n \t\tOPT_CMDMODE(0, \"continue\", &cmd, N_(\"resume revert or cherry-pick sequence\"), 'c'),\n@@ -264,18 +265,22 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,\n \tfree(options);\n \n \tif (cmd == 'q') {\n-\t\tint ret = sequencer_remove_state(opts);\n+\t\tret = sequencer_remove_state(opts);\n \t\tif (!ret)\n \t\t\tremove_branch_state(the_repository, 0);\n \t\treturn ret;\n \t}\n-\tif (cmd == 'c')\n-\t\treturn sequencer_continue(the_repository, opts);\n \tif (cmd == 'a')\n \t\treturn sequencer_rollback(the_repository, opts);\n-\tif (cmd == 's')\n-\t\treturn sequencer_skip(the_repository, opts);\n-\treturn sequencer_pick_revisions(the_repository, opts);\n+\tif (cmd == 'c')\n+\t\tret = sequencer_continue(the_repository, opts);\n+\telse if (cmd == 's')\n+\t\tret = sequencer_skip(the_repository, opts);\n+\telse\n+\t\tret = sequencer_pick_revisions(the_repository, opts);\n+\tif (!ret)\n+\t\trun_auto_maintenance(the_repository, opts->quiet);\n+\treturn ret;\n }\n \n int cmd_revert(int argc,\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex cb5c3a1cb5..8056b39955 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -395,4 +395,18 @@ test_orig_head () {\n test_orig_head --apply\n test_orig_head --merge\n \n+test_expect_success 'rebase runs auto maintenance once it is done' '\n+\t# topic and main both add F2, so the pick conflicts and the rebase\n+\t# stops before the exec runs, and once more when the exec fails\n+\tgit checkout -b auto-maintenance topic &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n+\t\tgit rebase -x false main &&\n+\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n+\techo resolved >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail git rebase --continue &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt\n+'\n+\n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 5777dff496..1dbc42e768 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -721,4 +721,29 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \ttest_line_count = 4 commits\n '\n \n+test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n+\tpristine_detach base &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n+\t\tgit cherry-pick anotherpick yetanotherpick &&\n+\ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" sequence.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n+'\n+\n+test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '\n+\t# both picked and anotherpick conflict on foo, so \"--continue\" stops\n+\t# once more before \"--skip\" ends the sequence\n+\tpristine_detach initial &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n+\t\tgit cherry-pick base..anotherpick &&\n+\ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n+\techo resolved >foo &&\n+\tgit add foo &&\n+\ttest_must_fail git cherry-pick --continue &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n+\ttest_subcommand_flex git maintenance run --auto <end.txt\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"552831","messageId":"c51ea031ea0a82c24820ee6e06a57fb150074cc4.1789670534.git.gitgitgadget@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v5.git.1789670534.gitgitgadget@gmail.com","subject":"[PATCH v5 3/3] sequencer: disable auto maintenance in spawned commands","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-17T18:42:14Z","receivedAt":"2026-09-17T18:42:20Z","isPatch":true,"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nWhen the sequencer spawns \"git commit\" or \"git merge\", those commands\nrun \"git maintenance run --auto\" in the background, which can\ninterfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock\nor repacks deleting active packs).\n\nPass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the\nspawned commit, merge and exec commands. Appending it after the\nuser's own settings ensures it wins, and the environment reaches\nwhatever they spawn in turn.\n\nAuto maintenance now runs exactly once when the sequence\ncompletes. Commands run manually by the user while stopped are\nunaffected and continue to run auto maintenance normally.\n\nAssisted-by: Claude Fable 5.1\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n t/t3418-rebase-continue.sh      | 14 ++++++++----\n t/t3510-cherry-pick-sequence.sh | 14 +++++++++---\n 3 files changed, 56 insertions(+), 10 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 65afd100d9..e99ef09f02 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -234,6 +234,11 @@ struct replay_ctx {\n \t * Whether message contains a commit message.\n \t */\n \tunsigned have_message :1;\n+\t/*\n+\t * GIT_CONFIG_PARAMETERS for the commands we spawn, with auto\n+\t * maintenance turned off. Built on first use.\n+\t */\n+\tchar *config_parameters;\n };\n \n struct replay_ctx* replay_ctx_new(void)\n@@ -407,6 +412,7 @@ static void replay_ctx_release(struct replay_ctx *ctx)\n {\n \tstrbuf_release(&ctx->current_fixups);\n \tstrbuf_release(&ctx->message);\n+\tfree(ctx->config_parameters);\n }\n \n void replay_opts_release(struct replay_opts *opts)\n@@ -1107,6 +1113,27 @@ static int run_command_silent_on_success(struct child_process *cmd)\n \treturn rc;\n }\n \n+/*\n+ * Don't let the commands we spawn run auto maintenance. It would race\n+ * us for MERGE_RR.lock or delete packs we still have open. Our caller\n+ * runs it once the sequence is done.\n+ */\n+static void disable_auto_maintenance(struct replay_opts *opts,\n+\t\t\t\t     struct child_process *cmd)\n+{\n+\tif (!opts->ctx->config_parameters) {\n+\t\tconst char *old = getenv(CONFIG_DATA_ENVIRONMENT);\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n+\t\tif (old && *old)\n+\t\t\tstrbuf_addstr(&buf, old);\n+\t\tgit_config_append_parameter(&buf, \"maintenance.auto\", \"false\");\n+\t\topts->ctx->config_parameters = strbuf_detach(&buf, NULL);\n+\t}\n+\tstrvec_pushf(&cmd->env, \"%s=%s\", CONFIG_DATA_ENVIRONMENT,\n+\t\t     opts->ctx->config_parameters);\n+}\n+\n /*\n  * If we are cherry-pick, and if the merge did not result in\n  * hand-editing, we will hit this commit and inherit the original\n@@ -1148,6 +1175,7 @@ static int run_git_commit(const char *defmsg,\n \t\t\t     author_date_from_env(&cmd.env));\n \tif (opts->ignore_date)\n \t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \n \tstrvec_push(&cmd.args, \"commit\");\n \n@@ -3924,16 +3952,18 @@ static int error_failed_squash(struct repository *r,\n \treturn error_with_patch(r, commit, subject, subject_len, opts, 1, 1);\n }\n \n-static int do_exec(struct repository *r, const char *command_line, int quiet)\n+static int do_exec(struct repository *r, const char *command_line,\n+\t\t   struct replay_opts *opts)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tint dirty, status;\n \n-\tif (!quiet)\n+\tif (!opts->quiet)\n \t\tfprintf(stderr, _(\"Executing: %s\\n\"), command_line);\n \tcmd.use_shell = 1;\n \tstrvec_push(&cmd.args, command_line);\n \tstrvec_push(&cmd.env, \"GIT_CHERRY_PICK_HELP\");\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstatus = run_command(&cmd);\n \n \t/* force re-reading of the cache */\n@@ -4342,6 +4372,7 @@ static int do_merge(struct repository *r,\n \t\t\t\t     author_date_from_env(&cmd.env));\n \t\tif (opts->ignore_date)\n \t\t\tstrvec_push(&cmd.env, \"GIT_AUTHOR_DATE=\");\n+\t\tdisable_auto_maintenance(opts, &cmd);\n \n \t\tcmd.git_cmd = 1;\n \t\tstrvec_push(&cmd.args, \"merge\");\n@@ -5158,7 +5189,7 @@ static int pick_commits(struct repository *r,\n \t\t\tif (!opts->verbose)\n \t\t\t\tterm_clear_line();\n \t\t\t*end_of_arg = '\\0';\n-\t\t\tres = do_exec(r, arg, opts->quiet);\n+\t\t\tres = do_exec(r, arg, opts);\n \t\t\t*end_of_arg = saved;\n \n \t\t\tif (res) {\n@@ -5329,6 +5360,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)\n \t\treturn error(_(\"no cherry-pick or revert in progress\"));\n \n \tcmd.git_cmd = 1;\n+\tdisable_auto_maintenance(opts, &cmd);\n \tstrvec_push(&cmd.args, \"commit\");\n \n \t/*\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 8056b39955..8c43ef64fc 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -397,16 +397,22 @@ test_orig_head --merge\n \n test_expect_success 'rebase runs auto maintenance once it is done' '\n \t# topic and main both add F2, so the pick conflicts and the rebase\n-\t# stops before the exec runs, and once more when the exec fails\n+\t# stops before the exec runs. \"--continue\" commits the resolution\n+\t# first, then runs the exec, which fails and stops it again.\n \tgit checkout -b auto-maintenance topic &&\n \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n-\t\tgit rebase -x false main &&\n+\t\tgit rebase -x \"git commit --allow-empty -m exec && false\" main &&\n \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n \techo resolved >F2 &&\n \tgit add F2 &&\n-\ttest_must_fail git rebase --continue &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit rebase --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git rebase --continue &&\n-\ttest_subcommand_flex git maintenance run --auto <end.txt\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n '\n \n test_done\ndiff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh\nindex 1dbc42e768..9400ddfc45 100755\n--- a/t/t3510-cherry-pick-sequence.sh\n+++ b/t/t3510-cherry-pick-sequence.sh\n@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' '\n \n test_expect_success 'cherry-pick runs auto maintenance once it is done' '\n \tpristine_detach base &&\n-\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick picked &&\n+\tGIT_TRACE2_EVENT=\"$(pwd)/single.txt\" git cherry-pick --edit picked &&\n+\ttest_subcommand_flex git commit <single.txt &&\n \ttest_subcommand_flex git maintenance run --auto <single.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" single.txt >maintenance &&\n+\ttest_line_count = 1 maintenance &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/sequence.txt\" \\\n \t\tgit cherry-pick anotherpick yetanotherpick &&\n \ttest_subcommand_flex git maintenance run --auto <sequence.txt &&\n@@ -741,9 +744,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i\n \ttest_subcommand_flex ! git maintenance run --auto <stop.txt &&\n \techo resolved >foo &&\n \tgit add foo &&\n-\ttest_must_fail git cherry-pick --continue &&\n+\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/mid.txt\" \\\n+\t\tgit cherry-pick --continue &&\n+\ttest_subcommand_flex git commit <mid.txt &&\n+\ttest_subcommand_flex ! git maintenance run --auto <mid.txt &&\n \tGIT_TRACE2_EVENT=\"$(pwd)/end.txt\" git cherry-pick --skip &&\n-\ttest_subcommand_flex git maintenance run --auto <end.txt\n+\ttest_subcommand_flex git maintenance run --auto <end.txt &&\n+\tgrep \"\\\"child_start\\\".*\\\"maintenance\\\"\" end.txt >maintenance &&\n+\ttest_line_count = 1 maintenance\n '\n \n test_done\n-- \ngitgitgadget\n"},{"id":"552971","messageId":"CAA0xjtpEXxuEkQRjwVACYfbk97WRdygi5W5ODaEF_5rfH5w+fQ@mail.gmail.com","threadId":"66269","inReplyTo":"aqOvAttPrhUIP_7U@pks.im","subject":"Re: [PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-09-22T07:38:10Z","receivedAt":"2026-09-22T07:38:23Z","isPatch":true,"body":"Hi Patrick,\n\nOn 11/09/2026 09:34, Patrick Steinhardt wrote:\n> The only exception that I could spot is when we abort the sequencer. But\n> I'd rather have us call auto-maintenance when `pick_commits()` is done\n> and when we abort rather than having every user of the sequencer do it\n> manually.\n>\n> Or am I missing something here?\n\nThe single picks. \"git cherry-pick <commit>\" and \"git revert <commit>\"\nreturn from sequencer_pick_revisions() through single_pick(). Their\n\"--continue\" returns from sequencer_continue() through\ncontinue_single_pick() when there is no todo file, and their \"--skip\"\nfrom sequencer_skip() when there is no sequencer directory. None of the\nthree reaches pick_commits().\n\nThe paragraph you proposed for 2/3 says it too:\n\n> Unfortunately, there is no single exit point for this backend where we\n> could add a call to `run_auto_maintenance()`. While one might expect\n> that we could simply trigger auto-maintenance in `pick_commits()` and\n> call it a day, a single pick as it is performed by e.g. git-revert(1)\n> never executes that function. So instead, manually trigger\n> auto-maintenance at several sites.\n\n2/3 in v5 names those three returns. My answer went out under the 1/3\nsubject by mistake [1].\n\nPhillip's answer when I offered the move [2]:\n\n> That works for we and means we don't have to sprinkle calls to\n> run_auto_maintenance() around to accommodate the different code paths\n> for single and multiple picks.\n\nSo inside the sequencer the call would go to the end of pick_commits(),\nto those three returns, and to the aborts. \"git rebase --abort\" already\nruns it from finish_rebase(), so that leaves the cherry-pick and revert\naborts. The two builtins are the sequencer's only callers, which is why\nI moved it there. Both work for me, say which and I'll reroll.\n\nThanks,\nThomas\n\n[1] <CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com>\n[2] <1e9f7b72-9f77-46e9-950e-df60b5a0539f@gmail.com>\n"},{"id":"553065","messageId":"c67ed25c-e54b-4289-bfb4-67f86beb6df6@gmail.com","threadId":"66269","inReplyTo":"pull.2217.v5.git.1789670534.gitgitgadget@gmail.com","subject":"Re: [PATCH v5 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-09-23T15:07:23Z","receivedAt":"2026-09-23T15:07:28Z","isPatch":true,"body":"Hi Thomas\n\nOn 17/09/2026 19:42, Thomas Bachem via GitGitGadget wrote:\n> Changes since v4:\n> \n>   * 2/3 takes Patrick's wording, with two corrections: the sequencer itself\n>     spawns the \"git commit\" for a resolved conflict, and the apply backend\n>     belongs to \"git rebase\", not to the sequencer.\n>   * 3/3 opens with Phillip's sentence.\n>   * The header comment of git_config_append_parameter() is Patrick's, plus\n>     one sentence on a NULL value.\n>   * Both tests got a comment on which picks conflict and where the sequence\n>     stops (Phillip).\n\nThanks for adding that, it is easier to understand what the tests are \ndoing now. This looks ready for next to me.\n\nThanks for working on it\n\nPhillip\n\n> \n> The code is unchanged.\n> \n> Patrick, my answer to your question on 2/3 went out under the 1/3 subject by\n> mistake [1]. The single picks are another exception: a \"git cherry-pick\n> <commit>\" or \"git revert <commit>\" never reaches pick_commits(), and neither\n> does its \"--continue\" or \"--skip\". So inside the sequencer the call would go\n> to the end of pick_commits() and to those three places, plus the aborts if\n> you want them. I kept it in the two builtins, which Phillip preferred, and\n> 2/3 now says why. Say if you'd rather have it in the sequencer and I'll move\n> it.\n> \n> Based on master. Independent of the rerere series in [2].\n> \n> [1] <CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com>\n> \n> [2] <pull.2214.v4.git.1789373061.gitgitgadget@gmail.com>\n> \n> Thomas Bachem (3):\n>    config: add git_config_append_parameter()\n>    rebase, cherry-pick, revert: run auto maintenance when done\n>    sequencer: disable auto maintenance in spawned commands\n> \n>   builtin/rebase.c                | 13 ++++++++---\n>   builtin/revert.c                | 19 +++++++++++------\n>   config.c                        | 20 +++++++++++------\n>   config.h                        | 12 +++++++++++\n>   sequencer.c                     | 38 ++++++++++++++++++++++++++++++---\n>   t/t3418-rebase-continue.sh      | 20 +++++++++++++++++\n>   t/t3510-cherry-pick-sequence.sh | 33 ++++++++++++++++++++++++++++\n>   7 files changed, 135 insertions(+), 20 deletions(-)\n> \n> \n> base-commit: 3cb9185f65410273787f74333cc027d2ea5daada\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v5\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v5\n> Pull-Request: https://github.com/gitgitgadget/git/pull/2217\n> \n> Range-diff vs v4:\n> \n>   1:  0472fadbc5 ! 1:  724baf2789 config: add git_config_append_parameter()\n>       @@ config.h: int git_config_from_blob_oid(config_fn_t fn, const char *name,\n>         void git_config_push_env(const char *spec);\n>        +\n>        +/*\n>       -+ * Append a \"-c key=value\" setting to a GIT_CONFIG_PARAMETERS value in\n>       -+ * `env`. The variable carries such settings from a git process to the\n>       -+ * git commands it spawns, as a space separated list of 'key'='value'\n>       -+ * pairs with both sides single quoted, which git_config_from_parameters()\n>       -+ * reads back. A NULL `value` appends 'key'= with nothing after the equals\n>       -+ * sign, which stands for a boolean true, like \"-c key\" on the command\n>       -+ * line.\n>       ++ * Append a config option to the buffer that can be exported via the\n>       ++ * GIT_CONFIG_PARAMETERS environment variable, which allows us to\n>       ++ * propagate configuration across Git processes. The format of the\n>       ++ * variable is a space-separated list of quoted \"'<key>'='<value>'\"\n>       ++ * pairs. With a NULL `value`, only 'key'= is appended, which git reads\n>       ++ * back as a boolean true, like \"-c key\" on the command line.\n>        + */\n>        +void git_config_append_parameter(struct strbuf *env, const char *key,\n>        +\t\t\t\t const char *value);\n>   2:  b7b97262f2 ! 2:  f0ec8f1f41 rebase, cherry-pick, revert: run auto maintenance when done\n>       @@ Metadata\n>         ## Commit message ##\n>            rebase, cherry-pick, revert: run auto maintenance when done\n>        \n>       -    \"git cherry-pick\", \"git revert\" and the merge backend of \"git rebase\"\n>       -    create their commits in process, so auto maintenance runs only when\n>       -    they spawn a command that runs it, like the \"git commit\" for a\n>       -    resolved conflict. A sequence thus runs it in the middle, after each\n>       -    resolution, or never.\n>       +    Commands that use the sequencer with the \"merge\" backend, like\n>       +    git-cherry-pick(1) or git-rebase(1) with \"--merge\", create their\n>       +    commits in-process. Consequently, these commands typically don't\n>       +    execute auto maintenance at all. Only the commands they spawn on the\n>       +    way run it, like git-commit(1) for a resolved conflict or an edited\n>       +    message.\n>        \n>       -    Run it once when the sequence is done, like the apply backend does.\n>       +    In contrast to that, the \"apply\" backend of git-rebase(1) _does_ run\n>       +    auto maintenance after it has processed the sequence of commits. And\n>       +    this is a sensible thing to do: after all, we may just have written\n>       +    lots of objects, so chances are high that we have something to clean\n>       +    up now.\n>        \n>       -    The sequencer has no single place where every sequence ends: a\n>       -    sequence of several commits ends in pick_commits(), a single pick\n>       -    returns as soon as its commit is made, and \"--continue\" and \"--skip\"\n>       -    have entry points of their own. Run it from the two builtins that\n>       -    start or continue a sequence instead: run_specific_rebase() once the\n>       -    sequencer has returned and removed its state directory, and\n>       -    run_sequencer() after a successful pick, \"--continue\" or \"--skip\".\n>       +    Adapt users of the \"merge\" backend to do the same.\n>       +\n>       +    The sequencer has no single exit where a call to run_auto_maintenance()\n>       +    could go. A sequence ends in pick_commits(), but a single pick never\n>       +    gets there: it returns from sequencer_pick_revisions() via\n>       +    single_pick(), its \"--continue\" from sequencer_continue() via\n>       +    continue_single_pick(), and its \"--skip\" from sequencer_skip(). So\n>       +    call it from the sequencer's two callers instead: run_specific_rebase()\n>       +    for the merge backend, once its state directory is gone, and\n>       +    run_sequencer() in builtin/revert.c after a successful pick,\n>       +    \"--continue\" or \"--skip\".\n>        \n>            Assisted-by: Claude Fable 5.1\n>            Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n>       @@ t/t3418-rebase-continue.sh: test_orig_head () {\n>         test_orig_head --merge\n>         \n>        +test_expect_success 'rebase runs auto maintenance once it is done' '\n>       ++\t# topic and main both add F2, so the pick conflicts and the rebase\n>       ++\t# stops before the exec runs, and once more when the exec fails\n>        +\tgit checkout -b auto-maintenance topic &&\n>        +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n>        +\t\tgit rebase -x false main &&\n>       @@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in ins\n>        +'\n>        +\n>        +test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '\n>       ++\t# both picked and anotherpick conflict on foo, so \"--continue\" stops\n>       ++\t# once more before \"--skip\" ends the sequence\n>        +\tpristine_detach initial &&\n>        +\ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n>        +\t\tgit cherry-pick base..anotherpick &&\n>   3:  031b3bd498 ! 3:  c51ea031ea sequencer: disable auto maintenance in spawned commands\n>       @@ Metadata\n>         ## Commit message ##\n>            sequencer: disable auto maintenance in spawned commands\n>        \n>       -    Sequencer-spawned commands like 'commit' and 'merge' run\n>       -    background auto maintenance, which interferes with ongoing\n>       -    operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks\n>       -    deleting active packs).\n>       +    When the sequencer spawns \"git commit\" or \"git merge\", those commands\n>       +    run \"git maintenance run --auto\" in the background, which can\n>       +    interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock\n>       +    or repacks deleting active packs).\n>        \n>            Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the\n>            spawned commit, merge and exec commands. Appending it after the\n>       @@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay\n>        \n>         ## t/t3418-rebase-continue.sh ##\n>        @@ t/t3418-rebase-continue.sh: test_orig_head --merge\n>       +\n>         test_expect_success 'rebase runs auto maintenance once it is done' '\n>       + \t# topic and main both add F2, so the pick conflicts and the rebase\n>       +-\t# stops before the exec runs, and once more when the exec fails\n>       ++\t# stops before the exec runs. \"--continue\" commits the resolution\n>       ++\t# first, then runs the exec, which fails and stops it again.\n>         \tgit checkout -b auto-maintenance topic &&\n>         \ttest_must_fail env GIT_TRACE2_EVENT=\"$(pwd)/stop.txt\" \\\n>        -\t\tgit rebase -x false main &&\n> \n\n"},{"id":"553418","messageId":"arob9B6PGV_T3Fmg@pks.im","threadId":"66269","inReplyTo":"c67ed25c-e54b-4289-bfb4-67f86beb6df6@gmail.com","subject":"Re: [PATCH v5 0/3] sequencer: leave auto maintenance to the end of a sequence","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-09-28T07:49:08Z","receivedAt":"2026-09-28T07:49:15Z","isPatch":true,"body":"On Wed, Sep 23, 2026 at 04:07:23PM +0100, Phillip Wood wrote:\n> Hi Thomas\n> \n> On 17/09/2026 19:42, Thomas Bachem via GitGitGadget wrote:\n> > Changes since v4:\n> > \n> >   * 2/3 takes Patrick's wording, with two corrections: the sequencer itself\n> >     spawns the \"git commit\" for a resolved conflict, and the apply backend\n> >     belongs to \"git rebase\", not to the sequencer.\n> >   * 3/3 opens with Phillip's sentence.\n> >   * The header comment of git_config_append_parameter() is Patrick's, plus\n> >     one sentence on a NULL value.\n> >   * Both tests got a comment on which picks conflict and where the sequence\n> >     stops (Phillip).\n> \n> Thanks for adding that, it is easier to understand what the tests are doing\n> now. This looks ready for next to me.\n> \n> Thanks for working on it\n\nIt's already been merged to `next` anyway, but agreed, this looks ready\nto me. Thanks!\n\nPatrick\n"}]}