sequencer: leave auto maintenance to the end of a rebase
cover sequencer: leave auto maintenance to the end of a rebase
While looking into the rerere lock race in [1], the "git commit" a rebase spawns for a resolved pick turned out to be about the only place a rebase with the merge backend runs auto maintenance, and it runs it against the rebase itself. Phillip asked for auto maintenance to be kept out of a rebase altogether [2], and for the merge backend to run it once at the end the way the apply backend does [3]. Patrick would rather see that discussed on its own [4], hence this series.
Patch 1 runs auto maintenance where the sequencer finishes a rebase, as the apply backend does. Patch 2 then passes maintenance.auto=false and gc.auto=0 to the "git commit", "git merge" and exec commands a rebase spawns, so that a rebase runs it once, at its end. Cherry-pick and revert are left as they are.
Based on master. Independent of [1], which makes the rerere lock non-fatal:
with both, a rebase neither spawns the gc nor dies on one that something else spawned.
[1] <[email protected]>
[2] <[email protected]>
[3] <[email protected]>
[4] <[email protected]>
Thomas Bachem (2):
sequencer: run auto maintenance once a rebase is done
sequencer: keep auto maintenance out of the commands a rebase spawns
sequencer.c | 32 ++++++++++++++++++++++++++++++++ t/t3418-rebase-continue.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+)
base-commit: 3cb9185f65410273787f74333cc027d2ea5daada
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2217
Signature · 1 line
gitgitgadget
PATCH 1/2 sequencer: run auto maintenance once a rebase is done
From: Thomas Bachem <[email protected]>
The apply backend runs "git maintenance run --auto" from finish_rebase() once it has applied its patches, and so does "git am" on its own. The merge backend reaches finish_rebase() only on the paths both backends share in builtin/rebase.c: an abort, a branch that is already up to date, and a fast-forward. A rebase that replays commits never runs maintenance at its end. It creates most of its commits in process, and only the "git commit" it spawns for a resolved, reworded or squashed pick, the "git merge" a "rebase -r" spawns for an octopus merge or with a strategy, and whatever an exec command runs kick maintenance off, in the middle of the rebase. Run it where the sequencer finishes a rebase, after the autostash is applied, as finish_rebase() does, so that both backends end a rebase the same way, and so that the next commit can keep it out of the commands a rebase spawns. builtin/rebase.c could run it instead once run_sequencer_rebase() returns, but the sequencer is where the rebase finishes, and the autostash and the state cleanup that surround the run in finish_rebase() are there as well. prepare_auto_maintenance() closes the object database before the spawn, so the sequencer holds nothing a repack would need to replace.
--- sequencer.c | 5 +++++ t/t3418-rebase-continue.sh | 8 ++++++++ 2 files changed, 13 insertions(+)
sequencer.c +5 -0
@@ -5297,6 +5297,11 @@ cleanup_head_ref:run_hooks_opt (r,"post-rewrite" , &hook_opt); }apply_autostash (rebase_path_autostash ()); +/* +* We ignore errors in 'git maintenance run --auto', since the +* user should see them. +*/ +run_auto_maintenance (r, opts->quiet);if (!opts->quiet) {if (!opts->verbose)
t/t3418-rebase-continue.sh +8 -0
@@ -395,4 +395,12 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance at its end' ' + git checkout -b one-exec main^ && + test_commit F4 && + test_must_fail git rebase -x false main && + GIT_TRACE2_EVENT="$(pwd)/finish.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <finish.txt +' + test_done
Signature · 1 line
gitgitgadget
PATCH 2/2 sequencer: keep auto maintenance out of the commands a rebase spawns
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
The commands a rebase with the merge backend spawns, the "git commit" for a resolved, reworded or squashed pick, the "git merge" of a "rebase -r" for an octopus merge or with a strategy, and whatever an exec command runs, each kick off "git maintenance run --auto --detach", a background process the rebase then races for the repository: the "rerere gc" spawned by the commit of one "git rebase --continue" holds MERGE_RR.lock while the next pick wants it, and a repack wants to delete packs the sequencer still had open, which 65cda10d5b (sequencer: release the ODB before spawning git commit, 2026-08-12) had to fix for Windows.
Nothing a rebase creates is old enough to be pruned by the time it ends, and repacking what it created can wait until then, so maintenance in the middle of a rebase has nothing to do that a run at its end cannot, and a rebase to get in the way of. Pass maintenance.auto=false and gc.auto=0 to the commands a rebase spawns, through GIT_CONFIG_PARAMETERS so that the shell of an exec command passes them on too, appended to whatever -c the user gave, since the last entry wins. What the user runs while the rebase is stopped, say "git commit --amend" at an edit, is not the rebase's to control and still runs it. "git commit" and "git merge" could skip it themselves while a rebase is in progress, which would cover that too, but that spreads the rebase's business over every command that runs maintenance and defers theirs for as long as a rebase is left lying around, so keep the decision with the rebase, in what it spawns. Both backends run maintenance once the rebase is done, the merge backend since the previous commit, so nothing is lost.
Cherry-pick and revert are left alone: they never ran maintenance at the end of a sequence, and the "git commit" they spawn for a --continue or an edited message is the only place they run it at all.
--- sequencer.c | 27 +++++++++++++++++++++++++++ t/t3418-rebase-continue.sh | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)
sequencer.c +27 -0
@@ -1107,6 +1107,29 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* A rebase runs auto maintenance once it is done, not from every command +* it spawns along the way: their background "rerere gc" or repack would +* race the rebase for locks and files it still holds. +*/ +static void disable_auto_maintenance (struct child_process *cmd) +{ +struct strbuf value =STRBUF_INIT ; +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); + +if (old && *old) +strbuf_addf (&value,"%s " , old); +sq_quote_buf (&value,"maintenance.auto" ); +strbuf_addch (&value,'=' ); +sq_quote_buf (&value,"false" ); +strbuf_addch (&value,' ' ); +sq_quote_buf (&value,"gc.auto" ); +strbuf_addch (&value,'=' ); +sq_quote_buf (&value,"0" ); +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , value.buf); +strbuf_release (&value); +} +/* * If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original
@@ -1148,6 +1171,8 @@ static int run_git_commit(const char *defmsg, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +if (is_rebase_i (opts)) +disable_auto_maintenance (&cmd);strvec_push (&cmd.args,"commit" );
@@ -3934,6 +3959,7 @@ static int do_exec(struct repository *r, const char *command_line, int quiet) cmd.use_shell =1 ;strvec_push (&cmd.args, command_line);strvec_push (&cmd.env,"GIT_CHERRY_PICK_HELP" ); +disable_auto_maintenance (&cmd); status =run_command (&cmd);/* force re-reading of the cache */
@@ -4342,6 +4368,7 @@ static int do_merge(struct repository *r, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (&cmd); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
t/t3418-rebase-continue.sh +18 -0
@@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' ' test_subcommand_flex git maintenance run --auto <finish.txt ' +test_expect_success 'rebase spawns no auto maintenance before its end' ' + git checkout -b two-conflicts topic && + test_commit F2-again F2 222 && + test_must_fail git rebase -x "git commit --allow-empty -m exec" main && + echo resolved >F2 && + git add F2 && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && + echo resolved >F2 && + git add F2 && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance +' + test_done
Signature · 1 line
gitgitgadget
Re: [PATCH 2/2] sequencer: keep auto maintenance out of the commands a rebase spawns
Hi Thomas
Quoted 12 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
The commands a rebase with the merge backend spawns, the "git commit" for a resolved, reworded or squashed pick, the "git merge" of a "rebase -r" for an octopus merge or with a strategy, and whatever an exec command runs, each kick off "git maintenance run --auto --detach", a background process the rebase then races for the repository: the "rerere gc" spawned by the commit of one "git rebase --continue" holds MERGE_RR.lock while the next pick wants it, and a repack wants to delete packs the sequencer still had open, which
65cda10d5b(sequencer: release the ODB before spawning git commit, 2026-08-12) had to fix for Windows.
This entire paragraph is a single sentence and is very hard to understand.
Quoted 1 line
Nothing a rebase creates is old enough to be pruned by the time it
s/Nothing/The objects/?
Quoted 1 line
ends, and repacking what it created can wait until then,
That's what we'll find out when this is merged. In principle it is possible someone is doing enormous rebases where the number of loose objects impacts the performance if we don't repack mid-rebase but I don't think we can know that without disabling auto maintenance and seeing if anyone complians.
Quoted 3 lines
so
maintenance in the middle of a rebase has nothing to do that a run at its end cannot, and a rebase to get in the way of.
That last clause is hard to parse.
Quoted 7 lines
Pass
maintenance.auto=false and gc.auto=0 to the commands a rebase spawns, throughGIT_CONFIG_PARAMETERSso that the shell of an exec command passes them on too, appended to whatever -c the user gave, since the last entry wins. What the user runs while the rebase is stopped, say "git commit --amend" at an edit, is not the rebase's to control and still runs it.
s/runs/run/
Quoted 11 lines
"git commit" and "git merge" could skip it themselves while a rebase is in progress, which would cover that too, but that spreads the rebase's business over every command that runs maintenance and defers theirs for as long as a rebase is left lying around, so keep the decision with the rebase, in what it spawns. Both backends run maintenance once the rebase is done, the merge backend since the previous commit, so nothing is lost.
Cherry-pick and revert are left alone: they never ran maintenance at the end of a sequence, and the "git commit" they spawn for a --continue or an edited message is the only place they run it at all.
I'm inclined to think that the reasoning for running maintenance at the end of a rebase applies to cherry-pick and probably revert as well.
Quoted 28 lines
Assisted-by Claude Fable 5.1Signed-off-by Thomas Bachem <[email protected]>--- sequencer.c | 27 +++++++++++++++++++++++++++ t/t3418-rebase-continue.sh | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+)sequencer.c +12
-0@@ -1107,6 +1107,29 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* A rebase runs auto maintenance once it is done, not from every command +* it spawns along the way: their background "rerere gc" or repack would +* race the rebase for locks and files it still holds. +*/ +static void disable_auto_maintenance (struct child_process *cmd) +{ +struct strbuf value =STRBUF_INIT ; +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); + +if (old && *old) +strbuf_addf (&value,"%s " , old);
sequencer.c static int run_command_silent_on_success(struct child_process *cmd) · line 1131
Quoted 10 lines
sequencer.c +10
-0+sq_quote_buf (&value,"maintenance.auto" ); +strbuf_addch (&value,'=' ); +sq_quote_buf (&value,"false" ); +strbuf_addch (&value,' ' ); +sq_quote_buf (&value,"gc.auto" ); +strbuf_addch (&value,'=' ); +sq_quote_buf (&value,"0" ); +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , value.buf); +strbuf_release (&value); +}
We already have a function in config.c to append parameters, but it sets them in the callers environment which we don't want to do here. I wonder if we could factor out a helper append the parameters to an strbuf passed by the caller so we don't need to know about the quoting scheme here. Also it would be nice to cache this in replay_ctx so we don't have to construct the string each time we want to disable auto maintenance.
Other than that this looks good
Thanks
Phillip
Quoted 56 lines
sequencer.c +5
-0+/* * If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original @@ -1148,6 +1171,8 @@ static int run_git_commit(const char *defmsg, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +if (is_rebase_i (opts)) +disable_auto_maintenance (&cmd);strvec_push (&cmd.args,"commit" );@@ -3934,6 +3959,7 @@ static int do_exec(struct repository *r, const char *command_line, int quiet) cmd.use_shell =1 ;strvec_push (&cmd.args, command_line);strvec_push (&cmd.env,"GIT_CHERRY_PICK_HELP" ); +disable_auto_maintenance (&cmd); status =run_command (&cmd);/* force re-reading of the cache */ @@ -4342,6 +4368,7 @@ static int do_merge(struct repository *r, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (&cmd); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );t/t3418-rebase-continue.sh +18
-0@@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' ' test_subcommand_flex git maintenance run --auto <finish.txt ' +test_expect_success 'rebase spawns no auto maintenance before its end' ' + git checkout -b two-conflicts topic && + test_commit F2-again F2 222 && + test_must_fail git rebase -x "git commit --allow-empty -m exec" main && + echo resolved >F2 && + git add F2 && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && + echo resolved >F2 && + git add F2 && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance +' + test_done
Re: [PATCH 1/2] sequencer: run auto maintenance once a rebase is done
In reply to Thomas Bachem via GitGitGadgetHi Thomas
Quoted 13 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
The apply backend runs "git maintenance run --auto" from
finish_rebase()once it has applied its patches, and so does "git am" on its own. The merge backend reachesfinish_rebase()only on the paths both backends share inbuiltin/rebase.c: an abort, a branch that is already up to date, and a fast-forward. A rebase that replays commits never runs maintenance at its end. It creates most of its commits in process, and only the "git commit" it spawns for a resolved, reworded or squashed pick, the "git merge" a "rebase -r" spawns for an octopus merge or with a strategy, and whatever an exec command runs kick maintenance off, in the middle of the rebase. Run it where the sequencer finishes a rebase, after the autostash is
Quoted 8 lines
applied, as
finish_rebase()does, so that both backends end a rebase the same way, and so that the next commit can keep it out of the commands a rebase spawns.builtin/rebase.ccould run it instead oncerun_sequencer_rebase()returns, but the sequencer is where the rebase finishes, and the autostash and the state cleanup that surround the run infinish_rebase()are there as well.prepare_auto_maintenance()closes the object database before the spawn, so the sequencer holds nothing a repack would need to replace.
It would be nice if the two backends shared more of the cleanup code, I don't think there is a good reason for them not to share the code that copies notes, applies the autostash and switches HEAD back to the branch, but that is outside the scope of this change. So adding a separate call to the sequencer code seems reasonable. I wonder if we should do this for cherry-pick and revert as well; certainly cherry-pick can create a lot of loose objects and does not necessarily call "git commit". If cherry-pick does call "git commit" and trigger background maintenance it is susceptible to the same problems as rebase, so we should probably treat them the same.
Thanks
Phillip
Quoted 41 lines
Assisted-by Claude Fable 5.1Signed-off-by Thomas Bachem <[email protected]>--- sequencer.c | 5 +++++ t/t3418-rebase-continue.sh | 8 ++++++++ 2 files changed, 13 insertions(+)sequencer.c +5
-0@@ -5297,6 +5297,11 @@ cleanup_head_ref:run_hooks_opt (r,"post-rewrite" , &hook_opt); }apply_autostash (rebase_path_autostash ()); +/* +* We ignore errors in 'git maintenance run --auto', since the +* user should see them. +*/ +run_auto_maintenance (r, opts->quiet);if (!opts->quiet) {if (!opts->verbose)t/t3418-rebase-continue.sh +8
-0@@ -395,4 +395,12 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance at its end' ' + git checkout -b one-exec main^ && + test_commit F4 && + test_must_fail git rebase -x false main && + GIT_TRACE2_EVENT="$(pwd)/finish.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <finish.txt +' + test_done
v2 cover sequencer: leave auto maintenance to the end of a sequence
In reply to Thomas Bachem via GitGitGadgetChanges since v1:
* Cherry-pick and revert end their sequences with auto maintenance too, and keep it out of the "git commit" they spawn, so the three commands now behave the same (Phillip).
* The GIT_CONFIG_PARAMETERS value comes from a helper split out of git_config_push_split_parameter() in config.c (new patch 1), built once per run and kept in replay_ctx (Phillip).
* Commit messages rewritten, much shorter (Junio, Phillip).
Based on master. Independent of the rerere lock fix in [1].
[1] <[email protected]>
Thomas Bachem (3):
config: add git_config_append_parameter()
sequencer: run auto maintenance once a sequence is done
sequencer: keep auto maintenance out of the commands a sequence spawns
config.c | 20 ++++++++---- config.h | 10 ++++++ sequencer.c | 57 +++++++++++++++++++++++++++++---- t/t3418-rebase-continue.sh | 26 +++++++++++++++ t/t3510-cherry-pick-sequence.sh | 27 ++++++++++++++++ 5 files changed, 127 insertions(+), 13 deletions(-)
base-commit: 3cb9185f65410273787f74333cc027d2ea5daada
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2217
Range-diff vs v1:
-: ---------- > 1: ef8087e80d config: add git_config_append_parameter() 1: 3415a4dcbf ! 2: baab8d4876 sequencer: run auto maintenance once a rebase is done
@@ Metadata
Author: Thomas Bachem <[email protected]>
## Commit message ##
- sequencer: run auto maintenance once a rebase is done
+ sequencer: run auto maintenance once a sequence is done
- The apply backend runs "git maintenance run --auto" from
- finish_rebase() once it has applied its patches, and so does "git am"
- on its own. The merge backend reaches finish_rebase() only on the
- paths both backends share in builtin/rebase.c: an abort, a branch
- that is already up to date, and a fast-forward. A rebase that
- replays commits never runs maintenance at its end. It creates most
- of its commits in process, and only the "git commit" it spawns for a
- resolved, reworded or squashed pick, the "git merge" a "rebase -r"
- spawns for an octopus merge or with a strategy, and whatever an exec
- command runs kick maintenance off, in the middle of the rebase. Run
- it where the sequencer finishes a rebase, after the autostash is
- applied, as finish_rebase() does, so that both backends end a rebase
- the same way, and so that the next commit can keep it out of the
- commands a rebase spawns. builtin/rebase.c could run it instead once
- run_sequencer_rebase() returns, but the sequencer is where the rebase
- finishes, and the autostash and the state cleanup that surround the
- run in finish_rebase() are there as well. prepare_auto_maintenance()
- closes the object database before the spawn, so the sequencer holds
- nothing a repack would need to replace.
+ The apply backend of "git rebase" runs "git maintenance run --auto"
+ from finish_rebase() once it has applied its patches. The merge
+ backend, "git cherry-pick" and "git revert" do not run it when they
+ finish. They create their commits in process, and only the "git
+ commit" they spawn for an edited message or a resolved conflict, the
+ "git merge" a "rebase -r" spawns and an exec command start it, in the
+ middle of the sequence.
+
+ Run it where the sequencer finishes, so that every sequence ends the
+ way the apply backend does, and so that the next commit can keep it
+ out of the commands a sequence spawns.
## sequencer.c ##
@@ sequencer.c: cleanup_head_ref:
- run_hooks_opt(r, "post-rewrite", &hook_opt);
+ return -1;
+ }
+
++ /*
++ * We ignore errors in 'git maintenance run --auto', since the
++ * user should see them.
++ */
++ run_auto_maintenance(r, opts->quiet);
++
+ /*
+ * Sequence of picks finished successfully; cleanup by
+ * removing the .git/sequencer directory
+@@ sequencer.c: int sequencer_continue(struct repository *r, struct replay_opts *opts)
+ res = -1;
+ goto release_todo_list;
}
- apply_autostash(rebase_path_autostash());
-+ /*
-+ * We ignore errors in 'git maintenance run --auto', since the
-+ * user should see them.
-+ */
-+ run_auto_maintenance(r, opts->quiet);
+- } else if (!file_exists(get_todo_path(opts)))
+- return continue_single_pick(r, opts);
+- else if ((res = read_populate_todo(r, &todo_list, opts)))
++ } else if (!file_exists(get_todo_path(opts))) {
++ res = continue_single_pick(r, opts);
++ if (!res)
++ run_auto_maintenance(r, opts->quiet);
++ return res;
++ } else if ((res = read_populate_todo(r, &todo_list, opts))) {
+ goto release_todo_list;
++ }
+
+ if (!is_rebase_i(opts)) {
+ /* Verify that the conflict has been resolved */
+@@ sequencer.c: int sequencer_pick_revisions(struct repository *r,
+ BUG("unexpected extra commit from walk");
+
+ res = single_pick(r, cmit, opts);
++ if (!res)
++ run_auto_maintenance(r, opts->quiet);
+ goto out;
+ }
- if (!opts->quiet) {
- if (!opts->verbose)
## t/t3418-rebase-continue.sh ##
@@ t/t3418-rebase-continue.sh: test_orig_head () {
@@ t/t3418-rebase-continue.sh: test_orig_head () {
+'
+
test_done
+
+ ## t/t3510-cherry-pick-sequence.sh ##
+@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in insn sheet are optional' '
+ test_line_count = 4 commits
+ '
+
++test_expect_success 'cherry-pick runs auto maintenance once it is done' '
++ pristine_detach base &&
++ GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked &&
++ test_subcommand_flex git maintenance run --auto <single.txt &&
++ GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \
++ git cherry-pick anotherpick yetanotherpick &&
++ grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance &&
++ test_line_count = 1 maintenance
++'
++
+ test_done
2: 06d2f0f484 ! 3: 9a6fc0427a sequencer: keep auto maintenance out of the commands a rebase spawns
@@ Metadata
Author: Thomas Bachem <[email protected]>
## Commit message ##
- sequencer: keep auto maintenance out of the commands a rebase spawns
+ sequencer: keep auto maintenance out of the commands a sequence spawns
- The commands a rebase with the merge backend spawns, the "git commit"
- for a resolved, reworded or squashed pick, the "git merge" of a
- "rebase -r" for an octopus merge or with a strategy, and whatever an
- exec command runs, each kick off "git maintenance run --auto --detach",
- a background process the rebase then races for the repository: the
- "rerere gc" spawned by the commit of one "git rebase --continue" holds
- MERGE_RR.lock while the next pick wants it, and a repack wants to
- delete packs the sequencer still had open, which 65cda10d5b
+ The "git commit" and "git merge" the sequencer spawns, and the git
+ commands an exec runs, each start "git maintenance run --auto
+ --detach", which then works in the background against the sequence
+ itself. A "rerere gc" started by the commit of one "git rebase
+ --continue" holds MERGE_RR.lock when the next pick needs it, and a
+ repack deletes packs the sequencer still has open, which 65cda10d5b
(sequencer: release the ODB before spawning git commit, 2026-08-12)
- had to fix for Windows.
+ had to work around.
- Nothing a rebase creates is old enough to be pruned by the time it
- ends, and repacking what it created can wait until then, so
- maintenance in the middle of a rebase has nothing to do that a run at
- its end cannot, and a rebase to get in the way of. Pass
- maintenance.auto=false and gc.auto=0 to the commands a rebase spawns,
- through GIT_CONFIG_PARAMETERS so that the shell of an exec command
- passes them on too, appended to whatever -c the user gave, since the
- last entry wins. What the user runs while the rebase is stopped, say
- "git commit --amend" at an edit, is not the rebase's to control and
- still runs it. "git commit" and "git merge" could skip it themselves
- while a rebase is in progress, which would cover that too, but that
- spreads the rebase's business over every command that runs
- maintenance and defers theirs for as long as a rebase is left lying
- around, so keep the decision with the rebase, in what it spawns. Both
- backends run maintenance once the rebase is done, the merge backend
- since the previous commit, so nothing is lost.
-
- Cherry-pick and revert are left alone: they never ran maintenance at
- the end of a sequence, and the "git commit" they spawn for a
- --continue or an edited message is the only place they run it at all.
+ The loose objects a sequence creates wait for the run at its end that
+ the previous commit added. Whether a sequence can be long enough to
+ suffer from them before that remains to be seen. Pass
+ maintenance.auto=false and gc.auto=0 to the spawned commands through
+ GIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to
+ whatever it runs, appended after the user's own -c settings so that
+ ours win, and built once per run. A command the user runs while the
+ sequence is stopped, like "git commit --amend" at an edit, is not the
+ sequencer's to control and still runs maintenance.
## sequencer.c ##
+@@ sequencer.c: struct replay_ctx {
+ * Whether message contains a commit message.
+ */
+ unsigned have_message :1;
++ /*
++ * The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out
++ * of the commands we spawn, built on first use.
++ */
++ struct strbuf config_parameters;
+ };
+
+ struct replay_ctx* replay_ctx_new(void)
+@@ sequencer.c: struct replay_ctx* replay_ctx_new(void)
+
+ strbuf_init(&ctx->current_fixups, 0);
+ strbuf_init(&ctx->message, 0);
++ strbuf_init(&ctx->config_parameters, 0);
+
+ return ctx;
+ }
+@@ sequencer.c: static void replay_ctx_release(struct replay_ctx *ctx)
+ {
+ strbuf_release(&ctx->current_fixups);
+ strbuf_release(&ctx->message);
++ strbuf_release(&ctx->config_parameters);
+ }
+
+ void replay_opts_release(struct replay_opts *opts)
@@ sequencer.c: static int run_command_silent_on_success(struct child_process *cmd)
return rc;
}
+/*
-+ * A rebase runs auto maintenance once it is done, not from every command ++ * A sequence runs auto maintenance once it is done, not from every command
+ * it spawns along the way: their background "rerere gc" or repack would
-+ * race the rebase for locks and files it still holds.
++ * race the sequencer for locks and files it still holds.
+ */
-+static void disable_auto_maintenance(struct child_process *cmd) ++static void disable_auto_maintenance(struct replay_opts *opts,
++ struct child_process *cmd)
+{
-+ struct strbuf value = STRBUF_INIT;
-+ const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
++ struct strbuf *params = &opts->ctx->config_parameters;
+
-+ if (old && *old)
-+ strbuf_addf(&value, "%s ", old);
-+ sq_quote_buf(&value, "maintenance.auto");
-+ strbuf_addch(&value, '=');
-+ sq_quote_buf(&value, "false");
-+ strbuf_addch(&value, ' ');
-+ sq_quote_buf(&value, "gc.auto");
-+ strbuf_addch(&value, '=');
-+ sq_quote_buf(&value, "0");
-+ strvec_pushf(&cmd->env, "%s=%s", CONFIG_DATA_ENVIRONMENT, value.buf);
-+ strbuf_release(&value);
++ if (!params->len) {
++ const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
++
++ if (old && *old)
++ strbuf_addstr(params, old);
++ git_config_append_parameter(params, "maintenance.auto", "false");
++ git_config_append_parameter(params, "gc.auto", "0");
++ }
++ strvec_pushf(&cmd->env, "%s=%s", CONFIG_DATA_ENVIRONMENT, params->buf);
+}
+
/*
@@ sequencer.c: static int run_git_commit(const char *defmsg,
author_date_from_env(&cmd.env));
if (opts->ignore_date)
strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
-+ if (is_rebase_i(opts))
-+ disable_auto_maintenance(&cmd);
++ disable_auto_maintenance(opts, &cmd);
strvec_push(&cmd.args, "commit");
-@@ sequencer.c: static int do_exec(struct repository *r, const char *command_line, int quiet) +@@ sequencer.c: static int error_failed_squash(struct repository *r,
+ return error_with_patch(r, commit, subject, subject_len, opts, 1, 1);
+ }
+
+-static int do_exec(struct repository *r, const char *command_line, int quiet) ++static int do_exec(struct repository *r, const char *command_line,
++ struct replay_opts *opts)
+ {
+ struct child_process cmd = CHILD_PROCESS_INIT;
+ int dirty, status;
+
+- if (!quiet)
++ if (!opts->quiet)
+ fprintf(stderr, _("Executing: %s\n"), command_line);
cmd.use_shell = 1;
strvec_push(&cmd.args, command_line);
strvec_push(&cmd.env, "GIT_CHERRY_PICK_HELP");
-+ disable_auto_maintenance(&cmd);
++ disable_auto_maintenance(opts, &cmd);
status = run_command(&cmd);
/* force re-reading of the cache */
@@ sequencer.c: static int do_merge(struct repository *r,
author_date_from_env(&cmd.env));
if (opts->ignore_date)
strvec_push(&cmd.env, "GIT_AUTHOR_DATE=");
-+ disable_auto_maintenance(&cmd);
++ disable_auto_maintenance(opts, &cmd);
cmd.git_cmd = 1;
strvec_push(&cmd.args, "merge");
+@@ sequencer.c: static int pick_commits(struct repository *r,
+ if (!opts->verbose)
+ term_clear_line();
+ *end_of_arg = '\0';
+- res = do_exec(r, arg, opts->quiet);
++ res = do_exec(r, arg, opts);
+ *end_of_arg = saved;
+
+ if (res) {
+@@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay_opts *opts)
+ return error(_("no cherry-pick or revert in progress"));
+
+ cmd.git_cmd = 1;
++ disable_auto_maintenance(opts, &cmd);
+ strvec_push(&cmd.args, "commit");
+
+ /*
## t/t3418-rebase-continue.sh ##
@@ t/t3418-rebase-continue.sh: test_expect_success 'rebase runs auto maintenance at its end' '
@@ t/t3418-rebase-continue.sh: test_expect_success 'rebase runs auto maintenance at
+'
+
test_done
+
+ ## t/t3510-cherry-pick-sequence.sh ##
+@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'cherry-pick runs auto maintenance once it is done' '
+ test_line_count = 1 maintenance
+ '
+
++test_expect_success 'cherry-pick spawns no auto maintenance before it is done' '
++ pristine_detach initial &&
++ test_must_fail git cherry-pick base..anotherpick &&
++ echo resolved >foo &&
++ git add foo &&
++ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \
++ git cherry-pick --continue &&
++ test_subcommand_flex git commit <mid.txt &&
++ test_subcommand_flex ! git maintenance run --auto <mid.txt &&
++ echo d >foo &&
++ git add foo &&
++ GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --continue &&
++ test_subcommand_flex git commit <end.txt &&
++ grep "\"child_start\".*\"maintenance\"" end.txt >maintenance &&
++ test_line_count = 1 maintenance
++'
++
+ test_done
Signature · 1 line
gitgitgadget
PATCH v2 1/3 config: add git_config_append_parameter()
From: Thomas Bachem <[email protected]>
Split the part of git_config_push_split_parameter() that formats one GIT_CONFIG_PARAMETERS entry into a helper that appends it to a strbuf, so that a caller can build a value for a child's environment without knowing the quoting. The sequencer is about to do that.
--- config.c | 20 +++++++++++++------- config.h | 10 ++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-)
config.c +13 -7
@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; } +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value) +{ +if (env->len) +strbuf_addch (env,' ' ); +sq_quote_buf (env, key); +strbuf_addch (env,'=' ); +if (value) +sq_quote_buf (env, value); +} +static void git_config_push_split_parameter (const char *key,const char *value) {struct strbuf env =STRBUF_INIT ;const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); -if (old && *old) { +if (old && *old)strbuf_addstr (&env, old); -strbuf_addch (&env,' ' ); - } -sq_quote_buf (&env, key); -strbuf_addch (&env,'=' ); -if (value) -sq_quote_buf (&env, value); +git_config_append_parameter (&env, key, value);setenv (CONFIG_DATA_ENVIRONMENT , env.buf,1 );strbuf_release (&env); }
config.h +10 -0
@@ -22,6 +22,7 @@*/ struct object_id ; +struct strbuf ;/* git_config_parse_key() returns these negated: */ #define CONFIG_INVALID_KEY 1
@@ -186,6 +187,15 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name, enum config_scope scope);void git_config_push_parameter (const char *text);void git_config_push_env (const char *spec); + +/* +* Append `key=value` to the GIT_CONFIG_PARAMETERS value in `env`, quoted +* the way git_config_from_parameters() reads it, so that a child can be +* given configuration on top of what this process was given. A NULL +* `value` appends a boolean entry. +*/ +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value);int git_config_from_parameters (config_fn_t fn,void *data);/*
Signature · 1 line
gitgitgadget
PATCH v2 2/3 sequencer: run auto maintenance once a sequence is done
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
The apply backend of "git rebase" runs "git maintenance run --auto" from finish_rebase() once it has applied its patches. The merge backend, "git cherry-pick" and "git revert" do not run it when they finish. They create their commits in process, and only the "git commit" they spawn for an edited message or a resolved conflict, the "git merge" a "rebase -r" spawns and an exec command start it, in the middle of the sequence.
Run it where the sequencer finishes, so that every sequence ends the way the apply backend does, and so that the next commit can keep it out of the commands a sequence spawns.
--- sequencer.c | 18 +++++++++++++++--- t/t3418-rebase-continue.sh | 8 ++++++++ t/t3510-cherry-pick-sequence.sh | 10 ++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-)
sequencer.c +15 -3
@@ -5313,6 +5313,12 @@ cleanup_head_ref:return -1 ; } +/* +* We ignore errors in 'git maintenance run --auto', since the +* user should see them. +*/ +run_auto_maintenance (r, opts->quiet); +/* * Sequence of picks finished successfully; cleanup by * removing the .git/sequencer directory
@@ -5577,10 +5583,14 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) res =-1 ; goto release_todo_list; } - }else if (!file_exists (get_todo_path (opts))) -return continue_single_pick (r, opts); -else if ((res =read_populate_todo (r, &todo_list, opts))) + }else if (!file_exists (get_todo_path (opts))) { + res =continue_single_pick (r, opts); +if (!res) +run_auto_maintenance (r, opts->quiet); +return res; + }else if ((res =read_populate_todo (r, &todo_list, opts))) { goto release_todo_list; + }if (!is_rebase_i (opts)) {/* Verify that the conflict has been resolved */
@@ -5698,6 +5708,8 @@ int sequencer_pick_revisions(struct repository *r,BUG ("unexpected extra commit from walk" ); res =single_pick (r, cmit, opts); +if (!res) +run_auto_maintenance (r, opts->quiet); goto out; }
t/t3418-rebase-continue.sh +8 -0
@@ -395,4 +395,12 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance at its end' ' + git checkout -b one-exec main^ && + test_commit F4 && + test_must_fail git rebase -x false main && + GIT_TRACE2_EVENT="$(pwd)/finish.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <finish.txt +' + test_done
t/t3510-cherry-pick-sequence.sh +10 -0
@@ -721,4 +721,14 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_line_count = 4 commits ' +test_expect_success 'cherry-pick runs auto maintenance once it is done' ' + pristine_detach base && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + test_subcommand_flex git maintenance run --auto <single.txt && + GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ + git cherry-pick anotherpick yetanotherpick && + grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance && + test_line_count = 1 maintenance +' + test_done
Signature · 1 line
gitgitgadget
PATCH v2 3/3 sequencer: keep auto maintenance out of the commands a sequence spawns
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
The "git commit" and "git merge" the sequencer spawns, and the git commands an exec runs, each start "git maintenance run --auto --detach", which then works in the background against the sequence itself. A "rerere gc" started by the commit of one "git rebase --continue" holds MERGE_RR.lock when the next pick needs it, and a repack deletes packs the sequencer still has open, which 65cda10d5b (sequencer: release the ODB before spawning git commit, 2026-08-12) had to work around.
The loose objects a sequence creates wait for the run at its end that the previous commit added. Whether a sequence can be long enough to suffer from them before that remains to be seen. Pass maintenance.auto=false and gc.auto=0 to the spawned commands through GIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to whatever it runs, appended after the user's own -c settings so that ours win, and built once per run. A command the user runs while the sequence is stopped, like "git commit --amend" at an edit, is not the sequencer's to control and still runs maintenance.
--- sequencer.c | 39 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 18 +++++++++++++++ t/t3510-cherry-pick-sequence.sh | 17 ++++++++++++++ 3 files changed, 71 insertions(+), 3 deletions(-)
sequencer.c +36 -3
@@ -234,6 +234,11 @@ struct replay_ctx {* Whether message contains a commit message. */ unsigned have_message :1; +/* +* The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out +* of the commands we spawn, built on first use. +*/ +struct strbuf config_parameters; };struct replay_ctx *replay_ctx_new (void )
@@ -242,6 +247,7 @@ struct replay_ctx* replay_ctx_new(void)strbuf_init (&ctx->current_fixups,0 );strbuf_init (&ctx->message,0 ); +strbuf_init (&ctx->config_parameters,0 );return ctx; }
@@ -407,6 +413,7 @@ static void replay_ctx_release(struct replay_ctx *ctx) {strbuf_release (&ctx->current_fixups);strbuf_release (&ctx->message); +strbuf_release (&ctx->config_parameters); }void replay_opts_release (struct replay_opts *opts)
@@ -1107,6 +1114,27 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* A sequence runs auto maintenance once it is done, not from every command +* it spawns along the way: their background "rerere gc" or repack would +* race the sequencer for locks and files it still holds. +*/ +static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +struct strbuf *params = &opts->ctx->config_parameters; + +if (!params->len) { +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); + +if (old && *old) +strbuf_addstr (params, old); +git_config_append_parameter (params,"maintenance.auto" ,"false" ); +git_config_append_parameter (params,"gc.auto" ,"0" ); + } +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , params->buf); +} +/* * If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original
@@ -1148,6 +1176,7 @@ static int run_git_commit(const char *defmsg, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );
@@ -3924,16 +3953,18 @@ static int error_failed_squash(struct repository *r,return error_with_patch (r, commit, subject, subject_len, opts,1 ,1 ); } -static int do_exec (struct repository *r,const char *command_line,int quiet) +static int do_exec (struct repository *r,const char *command_line, +struct replay_opts *opts) {struct child_process cmd =CHILD_PROCESS_INIT ;int dirty, status; -if (!quiet) +if (!opts->quiet)fprintf (stderr,_ ("Executing: %s\n" ), command_line); cmd.use_shell =1 ;strvec_push (&cmd.args, command_line);strvec_push (&cmd.env,"GIT_CHERRY_PICK_HELP" ); +disable_auto_maintenance (opts, &cmd); status =run_command (&cmd);/* force re-reading of the cache */
@@ -4342,6 +4373,7 @@ static int do_merge(struct repository *r, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
@@ -5158,7 +5190,7 @@ static int pick_commits(struct repository *r,if (!opts->verbose)term_clear_line (); *end_of_arg ='\0' ; - res =do_exec (r, arg, opts->quiet); + res =do_exec (r, arg, opts); *end_of_arg = saved;if (res) {
@@ -5335,6 +5367,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)return error (_ ("no cherry-pick or revert in progress" )); cmd.git_cmd =1 ; +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );/*
t/t3418-rebase-continue.sh +18 -0
@@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' ' test_subcommand_flex git maintenance run --auto <finish.txt ' +test_expect_success 'rebase spawns no auto maintenance before its end' ' + git checkout -b two-conflicts topic && + test_commit F2-again F2 222 && + test_must_fail git rebase -x "git commit --allow-empty -m exec" main && + echo resolved >F2 && + git add F2 && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && + echo resolved >F2 && + git add F2 && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance +' + test_done
t/t3510-cherry-pick-sequence.sh +17 -0
@@ -731,4 +731,21 @@ test_expect_success 'cherry-pick runs auto maintenance once it is done' ' test_line_count = 1 maintenance ' +test_expect_success 'cherry-pick spawns no auto maintenance before it is done' ' + pristine_detach initial && + test_must_fail git cherry-pick base..anotherpick && + echo resolved >foo && + git add foo && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git cherry-pick --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && + echo d >foo && + git add foo && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --continue && + test_subcommand_flex git commit <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance +' + test_done
Signature · 1 line
gitgitgadget
Re: [PATCH 2/2] sequencer: keep auto maintenance out of the commands a rebase spawns
In reply to Phillip WoodHi Phillip,
Quoted 1 line · Phillip Wood
That's what we'll find out when this is merged.
Agreed, and the message now says so instead of claiming it.
Quoted 2 lines
I'm inclined to think that the reasoning for running maintenance at the end of a rebase applies to cherry-pick and probably revert as well.
Agreed. In v2 all three end with one run where the sequencer finishes, and none of the commands they spawn run it, the "git commit" of a "cherry-pick --continue" included.
Quoted 5 lines
I wonder if we could factor out a helper append the parameters to an strbuf passed by the caller so we don't need to know about the quoting scheme here. Also it would be nice to cache this in
replay_ctxso we don't have to construct the string each time we want to disable auto maintenance.
Done, as a small config.c patch in front of the two, and a strbuf in replay_ctx built on first use.
The messages are rewritten from scratch and much shorter, the sentence you could not parse included.
Thanks,
Thomas
Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns
In reply to Thomas Bachem via GitGitGadgetsequencer.c struct replay_ctx { · line 241
Quoted 5 lines · Thomas Bachem via GitGitGadget
sequencer.c +5
-0+/* +* The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out +* of the commands we spawn, built on first use. +*/ +struct strbuf config_parameters;
Does this have to be a "struct strbuf", not "const char *"? The latter makes it clear that it will never change its value once you built it in disable_auto_maintenance().
Quoted 5 lines
sequencer.c +5
-0+static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +struct strbuf *params = &opts->ctx->config_parameters; +
sequencer.c static int run_command_silent_on_success(struct child_process *cmd) · line 1136
Quoted 10 lines
sequencer.c +10
-0+if (!params->len) { +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); + +if (old && *old) +strbuf_addstr (params, old); +git_config_append_parameter (params,"maintenance.auto" ,"false" ); +git_config_append_parameter (params,"gc.auto" ,"0" ); + } +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , params->buf); +}
This would then become something like
if (!opts->ctx->config_parameters) {
const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
struct strbuf params = STRBUF_INIT;
if (old && *old)
strbuf_addstr(¶ms, old);
git_config_append_parameter(¶ms, "maintenance.auto", "0");
git_config_append_parameter(¶ms, "gc.auto", "0");
opts->ctx->config_parameters = strbuf_detach(¶ms, NULL);
}
strbuf_pushf(..., opts->ctx->config_parameters);Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns
Hi Junio,
Quoted 3 lines · Junio C Hamano
Does this have to be a "struct strbuf", not "const char *"? The latter makes it clear that it will never change its value once you built it in
disable_auto_maintenance().
It doesn't. I'll make it a char * that replay_ctx_release() frees, built the way you sketch, in the next version.
Thanks,
Thomas
Re: [PATCH v2 1/3] config: add git_config_append_parameter()
In reply to Thomas Bachem via GitGitGadgetQuoted 6 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
Split the part of
git_config_push_split_parameter()that formats oneGIT_CONFIG_PARAMETERSentry into a helper that appends it to a strbuf, so that a caller can build a value for a child's environment without knowing the quoting. The sequencer is about to do that.
Readers who don't have any context around GIT_CONFIG_PARAMETERS and what it does will have a bit of a hard time making much sense of this, I think. It usually helps to give a sentence or two explaining what the infra even does, and what this quoting looks like.
Quoted 12 lines
Assisted-by Claude Fable 5.1Signed-off-by Thomas Bachem <[email protected]>--- config.c | 20 +++++++++++++------- config.h | 10 ++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-)config.c +0
-0
config.c static int git_config_include(const char *var, const char *value, · line 453
Quoted 4 lines
config.c +1
-0@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; } +void git_config_append_parameter(struct strbuf *env, const char *key,
Nit: callling this env assumes a bit too much about what this buffer is going to be used for. I'd have called it just buf.
Quoted 15 lines
config.h +1
-0@@ -22,6 +22,7 @@*/ struct object_id ; +struct strbuf ;/* git_config_parse_key() returns these negated: */ #define CONFIG_INVALID_KEY 1@@ -186,6 +187,15 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name, enum config_scope scope);void git_config_push_parameter (const char *text);
config.h int git_config_from_blob_oid(config_fn_t fn, const char *name, · line 198
Quoted 10 lines
config.h +9
-0void git_config_push_env (const char *spec); + +/* +* Append `key=value` to the GIT_CONFIG_PARAMETERS value in `env`, quoted +* the way git_config_from_parameters() reads it, so that a child can be +* given configuration on top of what this process was given. A NULL +* `value` appends a boolean entry. +*/ +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value);
Pointing to that other function makes sense, but neither of the functions documents the actual format that's used.
Patrick
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
In reply to Thomas Bachem via GitGitGadgetQuoted 9 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
The apply backend of "git rebase" runs "git maintenance run --auto" from
finish_rebase()once it has applied its patches. The merge backend, "git cherry-pick" and "git revert" do not run it when they finish. They create their commits in process, and only the "git commit" they spawn for an edited message or a resolved conflict, the "git merge" a "rebase -r" spawns and an exec command start it, in the middle of the sequence.
This paragraph just doesn't parse for me, it's really hard to tell what it even wants to say.
Quoted 3 lines
Run it where the sequencer finishes, so that every sequence ends the way the apply backend does, and so that the next commit can keep it out of the commands a sequence spawns.
Besides moving stuff around to prep for the next commit, what does this change? Like, do we now run the command in cases where we didn't before? And if so, what are the consequences of doing so?
Quoted 36 lines
sequencer.c +13
-3@@ -5313,6 +5313,12 @@ cleanup_head_ref:return -1 ; } +/* +* We ignore errors in 'git maintenance run --auto', since the +* user should see them. +*/ +run_auto_maintenance (r, opts->quiet); +/* * Sequence of picks finished successfully; cleanup by * removing the .git/sequencer directory @@ -5577,10 +5583,14 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) res =-1 ; goto release_todo_list; } - }else if (!file_exists (get_todo_path (opts))) -return continue_single_pick (r, opts); -else if ((res =read_populate_todo (r, &todo_list, opts))) + }else if (!file_exists (get_todo_path (opts))) { + res =continue_single_pick (r, opts); +if (!res) +run_auto_maintenance (r, opts->quiet); +return res; + }else if ((res =read_populate_todo (r, &todo_list, opts))) { goto release_todo_list; + }if (!is_rebase_i (opts)) {/* Verify that the conflict has been resolved */
sequencer.c int sequencer_pick_revisions(struct repository *r, · line 5715
Quoted 8 lines
sequencer.c +2
-0@@ -5698,6 +5708,8 @@ int sequencer_pick_revisions(struct repository *r,BUG ("unexpected extra commit from walk" ); res =single_pick (r, cmit, opts); +if (!res) +run_auto_maintenance (r, opts->quiet); goto out; }
It's surprisingly many sites where you add the call to run_auto_maintenance(). My hope was that there is a single exit path somewhere that is used by both the "apply" and "merge" strategy that we could adapt to unify when exactly we run auto-maintenance across both backends.
Patrick
Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns
In reply to Thomas Bachem via GitGitGadgetQuoted 19 lines · Thomas Bachem via GitGitGadget
sequencer.c +11
-0@@ -1107,6 +1114,27 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* A sequence runs auto maintenance once it is done, not from every command +* it spawns along the way: their background "rerere gc" or repack would +* race the sequencer for locks and files it still holds. +*/ +static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +struct strbuf *params = &opts->ctx->config_parameters; + +if (!params->len) {
sequencer.c static int run_command_silent_on_success(struct child_process *cmd) · line 1137
Quoted 10 lines
sequencer.c +10
-0+const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); + +if (old && *old) +strbuf_addstr (params, old); +git_config_append_parameter (params,"maintenance.auto" ,"false" ); +git_config_append_parameter (params,"gc.auto" ,"0" ); + } +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , params->buf); +} +
Why do you set both "maintenance.auto" and "gc.auto"? Setting only the former should be sufficient, as maintenance uses git-maintenance(1) exclusively nowadays. Sure, it may trigger git-gc(1) internally. But it won't ever do so if auto-maintenance is completely disabled.
Patrick
Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns
In reply to Thomas Bachem via GitGitGadgetQuoted 6 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
The "git commit" and "git merge" the sequencer spawns, and the git commands an exec runs, each start "git maintenance run --auto --detach", which then works in the background against the sequence itself.
I don't think maintenance is actively working against other commands, it just creates lock contention. Maybe something like
When the sequencer runs "git commit" or "git merge", either directly or via a user supplied exec command, those commands run "git maintenance --auto --detach" which can cause lock contention with the sequencer.
Quoted 5 lines
A "rerere gc" started by the commit of one "git rebase --continue" holds MERGE_RR.lock when the next pick needs it, and a repack deletes packs the sequencer still has open, which
65cda10d5b(sequencer: release the ODB before spawning git commit, 2026-08-12) had to work around.
This is pretty hard to understand. What does 'the commit of one "git rebase --continue"' mean? Also whether the next pick needs to take MERGE_RR.lock is conditional on there being conflicts which isn't at all clear.
Quoted 2 lines
The loose objects a sequence creates wait for the run at its end that the previous commit added.
What does that mean?
Quoted 5 lines
Whether a sequence can be long enough to
suffer from them before that remains to be seen. Pass maintenance.auto=false and gc.auto=0 to the spawned commands throughGIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to whatever it runs,
Talking about the shell here is unnecessarily confusing as the command is not necessarily run by the shell: if it is a single word that does not contain any shell metacharacters it is passed directly to exec()
Quoted 7 lines
appended after the user's own -c settings so that
ours win, and built once per run. A command the user runs while the sequence is stopped, like "git commit --amend" at an edit, is not the sequencer's to control and still runs maintenance.
sequencer.c static int run_command_silent_on_success(struct child_process *cmd) · line 1121
Quoted 8 lines
sequencer.c +5
-0@@ -1107,6 +1114,27 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* A sequence runs auto maintenance once it is done, not from every command +* it spawns along the way: their background "rerere gc" or repack would +* race the sequencer for locks and files it still holds. +*/
This comment isn't wrong but sounds like an LLM, rather than something a person would write.
sequencer.c static int run_command_silent_on_success(struct child_process *cmd) · line 1133
Quoted 12 lines
sequencer.c +12
-0+static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +struct strbuf *params = &opts->ctx->config_parameters; + +if (!params->len) { +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); + +if (old && *old) +strbuf_addstr (params, old); +git_config_append_parameter (params,"maintenance.auto" ,"false" ); +git_config_append_parameter (params,"gc.auto" ,"0" );
This is much nicer now we have the helper function and the calls to disable_auto_maintenance() that I've trimmed all look good.
Quoted 14 lines
t/t3418-rebase-continue.sh +6
-0@@ -403,4 +403,22 @@ test_expect_success 'rebase runs auto maintenance at its end' ' test_subcommand_flex git maintenance run --auto <finish.txt ' +test_expect_success 'rebase spawns no auto maintenance before its end' ' + git checkout -b two-conflicts topic && + test_commit F2-again F2 222 && + test_must_fail git rebase -x "git commit --allow-empty -m exec" main && + echo resolved >F2 && + git add F2 &&
t/t3418-rebase-continue.sh test_expect_success 'rebase runs auto maintenance at its end' ' · line 421
Quoted 10 lines
t/t3418-rebase-continue.sh +10
-0+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && + echo resolved >F2 && + git add F2 && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance
Shouldn't this just extend the test added in the previous patch, rather than duplicating the coverage for auto maintenance being run at the end of a rebase?
Quoted 16 lines
t/t3418-rebase-continue.sh +2
-0+' + test_donet/t3510-cherry-pick-sequence.sh +5
-0@@ -731,4 +731,21 @@ test_expect_success 'cherry-pick runs auto maintenance once it is done' ' test_line_count = 1 maintenance ' +test_expect_success 'cherry-pick spawns no auto maintenance before it is done' ' + pristine_detach initial && + test_must_fail git cherry-pick base..anotherpick && + echo resolved >foo && + git add foo &&
t/t3510-cherry-pick-sequence.sh test_expect_success 'cherry-pick runs auto maintenance once it is done' ' · line 748
Quoted 10 lines
t/t3510-cherry-pick-sequence.sh +10
-0+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git cherry-pick --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && + echo d >foo && + git add foo && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --continue && + test_subcommand_flex git commit <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance
Again why do we need a separate test, rather than extending the one we've just added in the previous commit?
Thanks
Phillip
Quoted 3 lines
t/t3510-cherry-pick-sequence.sh +2
-0+' + test_done
Re: [PATCH v2 1/3] config: add git_config_append_parameter()
In reply to Patrick SteinhardtQuoted 11 lines · Patrick Steinhardt
Quoted 10 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
config.c +0
-0@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; }
Quoted 4 lines
config.c static int git_config_include(const char *var, const char *value, · line 453
Quoted 1 line
config.c +1
-0+void git_config_append_parameter(struct strbuf *env, const char *key,Nit: callling this
envassumes a bit too much about what this buffer is going to be used for. I'd have called it justbuf.
Are we ever likely to use this outside of GIT_CONFIG_PARAMETERS? If not then I think env is a good name because it hints at where this function is used. Isn't the whole point of this function to allow us to append settings an environment variable?
Thanks
Phillip
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
In reply to Thomas Bachem via GitGitGadgetHi Thomas
Quoted 5 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
The apply backend of "git rebase" runs "git maintenance run --auto" from
finish_rebase()once it has applied its patches. The merge backend, "git cherry-pick" and "git revert" do not run it when they
The merge backend which is also used by "git cherry-pick" and "git revert" does not run it when it finishes.
would be clearer to me
Quoted 4 lines
finish. They create their commits in process, and only the "git commit" they spawn for an edited message or a resolved conflict, the "git merge" a "rebase -r" spawns and an exec command start it, in the middle of the sequence.
Like Patrick I cannot understand what this is saying, let alone whether it is saying anything useful.
Quoted 3 lines
Run it where the sequencer finishes, so that every sequence ends the way the apply backend does, and so that the next commit can keep it out of the commands a sequence spawns.
Run "git maintenace --auto" at the end of all sequencer operations,
...
would be clearer to me
sequencer.c cleanup_head_ref:
Quoted 5 lines
sequencer.c +0
-0@@ -5313,6 +5313,12 @@ cleanup_head_ref:
This makes me think we should change the fragment re for c files to exclude ':', but that's a digression and would mean having different expressions for c and c++.
Anyway this change is at the end of pick_commits(), just before we finish so looks like the right place to call run_auto_maintenance()
Quoted 13 lines
sequencer.c +6
-0return -1 ; } +/* +* We ignore errors in 'git maintenance run --auto', since the +* user should see them. +*/ +run_auto_maintenance (r, opts->quiet); +/* * Sequence of picks finished successfully; cleanup by * removing the .git/sequencer directory
sequencer.c int sequencer_continue(struct repository *r, struct replay_opts *opts) · line 5587
Quoted 8 lines
sequencer.c +2
-3@@ -5577,10 +5583,14 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) res =-1 ; goto release_todo_list; } - }else if (!file_exists (get_todo_path (opts))) -return continue_single_pick (r, opts); -else if ((res =read_populate_todo (r, &todo_list, opts))) + }else if (!file_exists (get_todo_path (opts))) { + res =continue_single_pick (r, opts);
It is a shame the single pick variants of "git cherry-pick" and "git revert" do not share the same code path as the multiple pick variants. continue_single_pick() runs "git commit" without calling run_git_commit() which is also unfortunate, but means that we could just rely and "git commit" to call run_auto_maintenance() for us.
Quoted 23 lines
sequencer.c +7
-0+if (!res) +run_auto_maintenance (r, opts->quiet); +return res; + }else if ((res =read_populate_todo (r, &todo_list, opts))) { goto release_todo_list; + }if (!is_rebase_i (opts)) {/* Verify that the conflict has been resolved */ @@ -5698,6 +5708,8 @@ int sequencer_pick_revisions(struct repository *r,BUG ("unexpected extra commit from walk" ); res =single_pick (r, cmit, opts); +if (!res) +run_auto_maintenance (r, opts->quiet); goto out; }t/t3418-rebase-continue.sh +0
-0
t/t3418-rebase-continue.sh test_orig_head () { · line 401
Quoted 7 lines
t/t3418-rebase-continue.sh +4
-0@@ -395,4 +395,12 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance at its end' ' + git checkout -b one-exec main^ && + test_commit F4 && + test_must_fail git rebase -x false main &&
Do we want to assert that we don't run auto maintenance up to this point?
Quoted 10 lines
t/t3418-rebase-continue.sh +4
-0+ GIT_TRACE2_EVENT="$(pwd)/finish.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <finish.txt +' + test_donet/t3510-cherry-pick-sequence.sh +0
-0
t/t3510-cherry-pick-sequence.sh test_expect_success 'commit descriptions in insn sheet are optional' ' · line 730
Quoted 10 lines
t/t3510-cherry-pick-sequence.sh +7
-0@@ -721,4 +721,14 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_line_count = 4 commits ' +test_expect_success 'cherry-pick runs auto maintenance once it is done' ' + pristine_detach base && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + test_subcommand_flex git maintenance run --auto <single.txt && + GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ + git cherry-pick anotherpick yetanotherpick && + grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance &&
Using test_grep here would mean we get some useful test output if there are not matches in the file. Without that test_line_count just says the line count didn't match and prints an empty file.
Thanks
Phillip
Quoted 4 lines
t/t3510-cherry-pick-sequence.sh +3
-0+ test_line_count = 1 maintenance +' + test_done
Re: [PATCH v2 1/3] config: add git_config_append_parameter()
In reply to Phillip WoodQuoted 16 lines · Phillip Wood
Quoted 14 lines · Patrick Steinhardt
config.c static int git_config_include(const char *var, const char *value, · line 452
Quoted 10 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
config.c +1
-0@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; } +void git_config_append_parameter(struct strbuf *env, const char *key,Nit: callling this
envassumes a bit too much about what this buffer is going to be used for. I'd have called it justbuf.
Quoted 4 lines
Are we ever likely to use this outside of
GIT_CONFIG_PARAMETERS? If not then I think env is a good name because it hints at where this function is used. Isn't the whole point of this function to allow us to append settings an environment variable?
Potentially, even though this function doesn't really require that at all. So it may or may not be used outside this current use case.
Anway, as I've said it's only a nit, so I won't insist on a change here.
Patrick
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
In reply to Patrick SteinhardtHi Patrick,
Quoted 2 lines · Patrick Steinhardt
This paragraph just doesn't parse for me, it's really hard to tell what it even wants to say.
Sorry, I'll rewrite it. What I meant: the apply backend runs auto maintenance from finish_rebase() when it is done. The merge backend, cherry-pick and revert create their commits in process and never run it themselves. It only runs when they spawn a command that runs it
anyway: "git commit" for an edited message or a resolved conflict, "git merge" for an octopus merge or a custom strategy in "rebase -r", or a git command in an exec. So a clean sequence never runs it, and one with conflicts runs it after each resolution, in the middle of the sequence.
Quoted 3 lines
Besides moving stuff around to prep for the next commit, what does this change? Like, do we now run the command in cases where we didn't before? And if so, what are the consequences of doing so?
Yes. After this patch every sequence that finishes runs it at the end, like a "git commit" or an apply backend rebase does. The next patch stops the runs in the middle, so it ends up as one run per sequence. The case that changes is a sequence with no conflict to resolve and no message to edit. Such a sequence never ran it at all, so its loose objects waited for the next commit. It is the same
"git maintenance run --auto --detach" as after a commit, so it runs in the background and does nothing unless a threshold is met. I'll put that in the message.
Quoted 5 lines
It's surprisingly many sites where you add the call to
run_auto_maintenance(). My hope was that there is a single exit path somewhere that is used by both the "apply" and "merge" strategy that we could adapt to unify when exactly we run auto-maintenance across both backends.
There is none inside the sequencer. run_specific_rebase() calls finish_rebase() for the apply backend only,
"merge backend cleans up after itself" as the comment there says. Sequences end inside pick_commits(), and a single cherry-pick or revert never creates sequencer state at all and returns straight to builtin/revert.c. That is where the three sites come from.
I could instead do what the apply backend already does. am.c skips maintenance in rebasing mode and leaves it to rebase.c. If the sequencer leaves it to its callers the same way, run_specific_rebase() runs it for the merge backend too, once its state directory is gone, and run_sequencer() in builtin/revert.c runs it for cherry-pick and revert. Every entry into the merge backend returns through run_specific_rebase(), --continue and --skip included, so nothing is missed. The sequencer then never runs it, the change is in the two builtins only, and the rule is short: the command runs it once when it is done, and nothing it spawns does. Is that what you had in mind?
Thanks,
Thomas
Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns
In reply to Patrick SteinhardtHi Patrick,
Quoted 4 lines · Patrick Steinhardt
Why do you set both "maintenance.auto" and "gc.auto"? Setting only the former should be sufficient, as maintenance uses git-maintenance(1) exclusively nowadays. Sure, it may trigger git-gc(1) internally. But it won't ever do so if auto-maintenance is completely disabled.
You're right. prepare_auto_maintenance() looks at gc.auto only when maintenance.auto is unset, so maintenance.auto alone is enough. gc.auto=0 would still stop an exec that runs "git gc --auto" itself, but I don't think we need to guard against that. I'll drop it in v3.
Thanks,
Thomas
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
In reply to Phillip WoodHi Phillip,
Quoted 4 lines · Phillip Wood
The merge backend which is also used by "git cherry-pick" and "git revert" does not run it when it finishes.
would be clearer to me
Yes, I'll use that.
Quoted 2 lines
Like Patrick I cannot understand what this is saying, let alone whether it is saying anything useful.
I've spelled it out in my reply to Patrick and will rewrite the message that way.
Quoted 4 lines
Run "git maintenace --auto" at the end of all sequencer operations,
...would be clearer to me
That too.
Quoted 2 lines
Anyway this change is at the end of
pick_commits(), just before we finish so looks like the right place to callrun_auto_maintenance()
Patrick would rather have one exit shared by both rebase backends. In my reply to him I've proposed moving the call out of the sequencer into builtin/rebase.c and builtin/revert.c, the way am.c leaves it to rebase.c today. Say if you'd rather keep it here.
Quoted 5 lines
It is a shame the single pick variants of "git cherry-pick" and "git revert" do not share the same code path as the multiple pick variants.
continue_single_pick()runs "git commit" without callingrun_git_commit()which is also unfortunate, but means that we could just rely and "git commit" to callrun_auto_maintenance()for us.
That works until the next patch, which turns auto maintenance off in every command the sequencer spawns, this "git commit" included. So somebody has to run it afterwards. With the call in builtin/revert.c, cherry-pick does that itself once the continue returns.
Quoted 1 line
Do we want to assert that we don't run auto maintenance up to this point?
Yes, I'll add that, and the next patch will extend this test instead of adding its own.
Quoted 3 lines
Using
test_grephere would mean we get some useful test output if there are not matches in the file. Without thattest_line_countjust says the line count didn't match and prints an empty file.
Will do.
Thanks,
Thomas
Re: [PATCH v2 3/3] sequencer: keep auto maintenance out of the commands a sequence spawns
In reply to Phillip WoodHi Phillip,
Quoted 7 lines · Phillip Wood
I don't think maintenance is actively working against other commands, it just creates lock contention. Maybe something like
When the sequencer runs "git commit" or "git merge", either directly or via a user supplied exec command, those commands run "git maintenance --auto --detach" which can cause lock contention with the sequencer.
I'll use that. The repack case is a bit different, though. It can delete a pack the sequencer still has open, which 65cda10d5b had to work around, so I'll keep one sentence on it.
Quoted 4 lines
This is pretty hard to understand. What does 'the commit of one "git rebase --continue"' mean? Also whether the next pick needs to take MERGE_RR.lock is conditional on there being conflicts which isn't at all clear.
I meant the "git commit" that "git rebase --continue" spawns for a resolved conflict. Its maintenance run can still hold MERGE_RR.lock when the next pick conflicts and rerere needs it. I'll write it like that.
Quoted 1 line
What does that mean?
Once the spawned commands no longer run maintenance, a long sequence can pile up loose objects, and nothing packs them before the run at the end. I don't know whether a sequence can get long enough for that to matter. I'll say it like this, or drop it.
Quoted 3 lines
Talking about the shell here is unnecessarily confusing as the command is not necessarily run by the shell: if it is a single word that does not contain any shell metacharacters it is passed directly to
exec()
Right, the environment reaches the command either way. I'll drop the shell from the message.
Quoted 2 lines
This comment isn't wrong but sounds like an LLM, rather than something a person would write.
I've rewritten it:
/*
* Don't let the commands we spawn run auto maintenance. It would
* race us for MERGE_RR.lock or delete packs we still have open,
* so it runs once at the end of the sequence instead. */
Quoted 3 lines
Shouldn't this just extend the test added in the previous patch, rather than duplicating the coverage for auto maintenance being run at the end of a rebase?
Yes, I'll extend both tests from the previous patch instead.
Thanks,
Thomas
Re: [PATCH v2 1/3] config: add git_config_append_parameter()
In reply to Patrick SteinhardtHi Patrick,
Quoted 4 lines · Patrick Steinhardt
Readers who don't have any context around
GIT_CONFIG_PARAMETERSand what it does will have a bit of a hard time making much sense of this, I think. It usually helps to give a sentence or two explaining what the infra even does, and what this quoting looks like.
Will do. It is how "git -c key=value" reaches the child processes: a space separated list of 'key'='value' pairs, each side single quoted, that git_config_from_parameters() reads back. I'll say that in the message.
Quoted 2 lines
Pointing to that other function makes sense, but neither of the functions documents the actual format that's used.
I'll put the format in the header comment as well.
Thanks,
Thomas
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
In reply to Thomas BachemHi Thomas
Quoted 8 lines · Thomas Bachem
Quoted 3 lines
Anyway this change is at the end of
pick_commits(), just before we finish so looks like the right place to callrun_auto_maintenance()Patrick would rather have one exit shared by both rebase backends. In my reply to him I've proposed moving the call out of the sequencer into
builtin/rebase.candbuiltin/revert.c, the wayam.cleaves it torebase.ctoday. Say if you'd rather keep it here.
That works for we and means we don't have to sprinkle calls to run_auto_maintenance() around to accommodate the different code paths for single and multiple picks.
Quoted 10 lines
Quoted 5 lines
It is a shame the single pick variants of "git cherry-pick" and "git revert" do not share the same code path as the multiple pick variants.
continue_single_pick()runs "git commit" without callingrun_git_commit()which is also unfortunate, but means that we could just rely and "git commit" to callrun_auto_maintenance()for us.That works until the next patch, which turns auto maintenance off in every command the sequencer spawns, this "git commit" included. So somebody has to run it afterwards. With the call in
builtin/revert.c, cherry-pick does that itself once the continue returns.
Sounds good
Thanks
Phillip
Quoted 14 lines
Quoted 2 lines
Do we want to assert that we don't run auto maintenance up to this point?
Yes, I'll add that, and the next patch will extend this test instead of adding its own.
Quoted 3 lines
Using
test_grephere would mean we get some useful test output if there are not matches in the file. Without thattest_line_countjust says the line count didn't match and prints an empty file.Will do.
Thanks,
Thomas
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
In reply to Thomas BachemQuoted 1 line · Thomas Bachem
On 07/09/2026 10:14, Patrick Steinhardt wrote:
[snip]
Quoted 13 lines
Quoted 5 lines
It's surprisingly many sites where you add the call to
run_auto_maintenance(). My hope was that there is a single exit path somewhere that is used by both the "apply" and "merge" strategy that we could adapt to unify when exactly we run auto-maintenance across both backends.There is none inside the sequencer.
run_specific_rebase()callsfinish_rebase()for the apply backend only,
"merge backend cleans up after itself" as the comment there says. Sequences end insidepick_commits(), and a single cherry-pick or revert never creates sequencer state at all and returns straight tobuiltin/revert.c. That is where the three sites come from.
Quoted 10 lines
I could instead do what the apply backend already does.
am.cskips maintenance in rebasing mode and leaves it torebase.c. If the sequencer leaves it to its callers the same way,run_specific_rebase()runs it for the merge backend too, once its state directory is gone, andrun_sequencer()inbuiltin/revert.cruns it for cherry-pick and revert. Every entry into the merge backend returns throughrun_specific_rebase(), --continue and --skip included, so nothing is missed. The sequencer then never runs it, the change is in the two builtins only, and the rule is short: the command runs it once when it is done, and nothing it spawns does. Is that what you had in mind?
Maybe. The question is what kind of impact it would have on other subsystems. I think the most important part that I'm after is that the commit message explains design decisions like this, as it gives the reader the required context to be able to evaluate the patch.
And please stay mindful of LLM-generated commit messages. For most of the part they are just completely useless as they tend to ramble without conveying any useful information. The commit message is the place where you yourself sell the change to us, and by explaining the changes well you demonstrate that you understand what you're sending to the mailing list.
An LLM-generated commit message on the other side demonstrates nothing like that. So in many cases, it's actively hurting your own mission as people do notice that it's not generated by humans.
It's fine to use LLMs to help you with drafting the commit message. But what we're asking is that you double or even triple check what was generated and whether the generated message (1) makes sense and (2) is understandable by a normal human being.
Thanks!
Patrick
Re: [PATCH v2 2/3] sequencer: run auto maintenance once a sequence is done
Hi Patrick,
Quoted 4 lines · Patrick Steinhardt
Maybe. The question is what kind of impact it would have on other subsystems. I think the most important part that I'm after is that the commit message explains design decisions like this, as it gives the reader the required context to be able to evaluate the patch.
None that I can see. Outside sequencer.c the sequencer is only entered from builtin/rebase.c and builtin/revert.c, so those two are the only places the call moves to. I'll put that, and why, in the commit message.
Quoted 4 lines
It's fine to use LLMs to help you with drafting the commit message. But what we're asking is that you double or even triple check what was generated and whether the generated message (1) makes sense and (2) is understandable by a normal human being.
Okay, I'll rewrite all three messages for v3.
Thanks,
Thomas
v3 cover sequencer: leave auto maintenance to the end of a sequence
In reply to Thomas Bachem via GitGitGadgetChanges since v2:
* Auto maintenance now runs from builtin/rebase.c and builtin/revert.c, once the command is done, instead of from three places inside the sequencer. That follows the apply backend, where "git am" leaves it to rebase.c (Patrick, Phillip).
* gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).
* config_parameters is a char * built once with strbuf_detach() (Junio).
* Patch 3 extends the tests of patch 2 instead of adding its own. They also assert that nothing runs before a stop, and cover a single pick with --edit and a sequence ending in --skip (Phillip).
* Commit messages rewritten: what GIT_CONFIG_PARAMETERS is and looks like (Patrick), what patch 2 changes for the user and why the call moved (Patrick, Phillip), and the comment on the helper (Phillip).
Based on master. Independent of the rerere lock fix in [1].
[1] <[email protected]>
Thomas Bachem (3):
config: add git_config_append_parameter()
rebase, cherry-pick, revert: run auto maintenance when done
sequencer: disable auto maintenance in spawned commands
builtin/rebase.c | 13 ++++++++--- builtin/revert.c | 19 +++++++++++------ config.c | 20 +++++++++++------ config.h | 13 +++++++++++ sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 17 +++++++++++++++ t/t3510-cherry-pick-sequence.sh | 31 +++++++++++++++++++++++++++ 7 files changed, 131 insertions(+), 20 deletions(-)
base-commit: 3cb9185f65410273787f74333cc027d2ea5daada
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/2217
Range-diff vs v2:
1: ef8087e80d ! 1: 70db5ad084 config: add git_config_append_parameter()
@@ Metadata
## Commit message ##
config: add git_config_append_parameter()
- Split the part of git_config_push_split_parameter() that formats one
- GIT_CONFIG_PARAMETERS entry into a helper that appends it to a strbuf,
- so that a caller can build a value for a child's environment without
- knowing the quoting. The sequencer is about to do that.
+ "git -c key=value" passes its settings on to the git commands it
+ spawns through the environment variable GIT_CONFIG_PARAMETERS. The
+ value is a space separated list of 'key'='value' pairs with both
+ sides single quoted, which git_config_from_parameters() reads back in
+ the child. The only place we write such an entry is
+ git_config_push_split_parameter(), and it writes straight into our
+ own environment.
+
+ Split the formatting out into git_config_append_parameter(), which
+ appends one entry to a strbuf, so that we can build such a value for
+ a child's environment without repeating the quoting. The sequencer
+ will use it in a later commit to pass settings to the commands it
+ spawns.
@@ config.h: int git_config_from_blob_oid(config_fn_t fn, const char *name,
void git_config_push_env(const char *spec);
+
+/*
-+ * Append key=value to the GIT_CONFIG_PARAMETERS value in env, quoted -+ * the way git_config_from_parameters() reads it, so that a child can be -+ * given configuration on top of what this process was given. A NULL -+ * value appends a boolean entry.
++ * Append a "-c key=value" setting to a GIT_CONFIG_PARAMETERS value in ++ * env. The variable carries such settings from a git process to the ++ * git commands it spawns, as a space separated list of 'key'='value' ++ * pairs with both sides single quoted, which git_config_from_parameters() ++ * reads back. A NULL value appends 'key'= with nothing after the equals ++ * sign, which stands for a boolean true, like "-c key" on the command ++ * line.
+ */
+void git_config_append_parameter(struct strbuf *env, const char *key,
+ const char *value);
2: baab8d4876 ! 2: 68a728c5f4 sequencer: run auto maintenance once a sequence is done
@@ Metadata
Author: Thomas Bachem <[email protected]>
## Commit message ##
- sequencer: run auto maintenance once a sequence is done
+ rebase, cherry-pick, revert: run auto maintenance when done
- The apply backend of "git rebase" runs "git maintenance run --auto"
- from finish_rebase() once it has applied its patches. The merge
- backend, "git cherry-pick" and "git revert" do not run it when they
- finish. They create their commits in process, and only the "git
- commit" they spawn for an edited message or a resolved conflict, the
- "git merge" a "rebase -r" spawns and an exec command start it, in the
- middle of the sequence.
+ "git commit", "git merge", "git fetch" and "git am" run "git
+ maintenance run --auto" when they are done, and so does the apply
+ backend of "git rebase". That repacks the loose objects they wrote
+ once there are enough of them, expires old rerere entries and does
+ whatever other housekeeping is due.
- Run it where the sequencer finishes, so that every sequence ends the
- way the apply backend does, and so that the next commit can keep it
- out of the commands a sequence spawns.
+ The merge backend of "git rebase", "git cherry-pick" and "git revert"
+ do not. They create their commits in process, so auto maintenance
+ runs only when they spawn a command that runs it on its own. That is
+ the "git commit" for a resolved conflict or an edited message, the
+ "git merge" that "--rebase-merges" spawns for an octopus merge, a
+ strategy other than ort or any strategy option, and whatever an exec
+ runs. A sequence that needs none of these never runs auto
+ maintenance. One that stops for conflicts runs it after each
+ resolution, in the middle of the sequence.
+
+ Run it once when the sequence is done, like the apply backend does.
+
+ The apply backend leaves that to builtin/rebase.c: "git am" skips
+ auto maintenance in rebasing mode, and finish_rebase() runs it once
+ the patches are applied. Do the same for the sequencer, from
+ builtin/rebase.c and builtin/revert.c, because the sequencer itself
+ has no single place where every sequence ends. A sequence of several
+ commits ends inside pick_commits(). A single cherry-pick or revert
+ never creates the sequencer's state directory and returns to its
+ caller as soon as its commit is made. "--continue" and "--skip" have
+ entry points of their own. Nothing but those two builtins starts or
+ continues a sequence, so that is where we run auto maintenance.
+ run_specific_rebase() runs it for the merge backend once the
+ sequencer has returned successfully and removed its state directory,
+ which it keeps while the rebase is stopped. run_sequencer() runs it
+ for cherry-pick and revert when a pick, a "--continue" or a "--skip"
+ returns successfully.
+
+ For the user, a sequence that never stops now runs auto maintenance
+ once when it is done, where it never ran it before. That is the same
+ "git maintenance run --auto --detach" as after "git commit": it
+ detaches into the background by default and does nothing unless one
+ of its tasks is due. The runs from the commands a sequence spawns
+ stay for now. The next commit removes them, so that a sequence runs
+ auto maintenance exactly once.
- ## sequencer.c ##
-@@ sequencer.c: cleanup_head_ref:
- return -1;
- }
+ ## builtin/rebase.c ##
+@@ builtin/rebase.c: static int run_specific_rebase(struct rebase_options *opts)
-+ /*
-+ * We ignore errors in 'git maintenance run --auto', since the
-+ * user should see them.
-+ */
-+ run_auto_maintenance(r, opts->quiet);
+ if (opts->dont_finish_rebase)
+ ; /* do nothing */
+- else if (opts->type == REBASE_MERGE)
+- ; /* merge backend cleans up after itself */
+- else if (status == 0) {
++ else if (opts->type == REBASE_MERGE) {
++ int quiet = !(opts->flags & (REBASE_NO_QUIET|REBASE_VERBOSE));
+
- /*
- * Sequence of picks finished successfully; cleanup by
- * removing the .git/sequencer directory
-@@ sequencer.c: int sequencer_continue(struct repository *r, struct replay_opts *opts)
- res = -1;
- goto release_todo_list;
- }
-- } else if (!file_exists(get_todo_path(opts)))
-- return continue_single_pick(r, opts);
-- else if ((res = read_populate_todo(r, &todo_list, opts)))
-+ } else if (!file_exists(get_todo_path(opts))) {
-+ res = continue_single_pick(r, opts);
-+ if (!res)
-+ run_auto_maintenance(r, opts->quiet);
-+ return res;
-+ } else if ((res = read_populate_todo(r, &todo_list, opts))) {
- goto release_todo_list;
-+ }
++ /*
++ * The sequencer cleans up after itself. Its state directory
++ * is gone once it is done, and stays while it is stopped.
++ */
++ if (status == 0 && !is_directory(opts->state_dir))
++ run_auto_maintenance(the_repository, quiet);
++ } else if (status == 0) {
+ if (!file_exists(state_dir_path("stopped-sha", opts)))
+ finish_rebase(opts);
+ } else if (status == 2) {
+
+ ## builtin/revert.c ##
+@@
+ #include "gettext.h"
+ #include "revision.h"
+ #include "rerere.h"
++#include "run-command.h"
+ #include "sequencer.h"
+ #include "branch.h"
- if (!is_rebase_i(opts)) {
- /* Verify that the conflict has been resolved */
-@@ sequencer.c: int sequencer_pick_revisions(struct repository *r,
- BUG("unexpected extra commit from walk");
+@@ builtin/revert.c: static int run_sequencer(int argc, const char **argv, const char *prefix,
+ const char *strategy = &sentinel_value;
+ const char *gpg_sign = &sentinel_value;
+ enum empty_action empty_opt = EMPTY_COMMIT_UNSPECIFIED;
+- int cmd = 0;
++ int cmd = 0, ret;
+ struct option base_options[] = {
+ OPT_CMDMODE(0, "quit", &cmd, N_("end revert or cherry-pick sequence"), 'q'),
+ OPT_CMDMODE(0, "continue", &cmd, N_("resume revert or cherry-pick sequence"), 'c'),
+@@ builtin/revert.c: static int run_sequencer(int argc, const char **argv, const char *prefix,
+ free(options);
- res = single_pick(r, cmit, opts);
-+ if (!res)
-+ run_auto_maintenance(r, opts->quiet);
- goto out;
+ if (cmd == 'q') {
+- int ret = sequencer_remove_state(opts);
++ ret = sequencer_remove_state(opts);
+ if (!ret)
+ remove_branch_state(the_repository, 0);
+ return ret;
}
+- if (cmd == 'c')
+- return sequencer_continue(the_repository, opts);
+ if (cmd == 'a')
+ return sequencer_rollback(the_repository, opts);
+- if (cmd == 's')
+- return sequencer_skip(the_repository, opts);
+- return sequencer_pick_revisions(the_repository, opts);
++ if (cmd == 'c')
++ ret = sequencer_continue(the_repository, opts);
++ else if (cmd == 's')
++ ret = sequencer_skip(the_repository, opts);
++ else
++ ret = sequencer_pick_revisions(the_repository, opts);
++ if (!ret)
++ run_auto_maintenance(the_repository, opts->quiet);
++ return ret;
+ }
+ int cmd_revert(int argc,
## t/t3418-rebase-continue.sh ##
@@ t/t3418-rebase-continue.sh: test_orig_head () {
test_orig_head --apply
test_orig_head --merge
-+test_expect_success 'rebase runs auto maintenance at its end' '
-+ git checkout -b one-exec main^ &&
-+ test_commit F4 &&
-+ test_must_fail git rebase -x false main &&
-+ GIT_TRACE2_EVENT="$(pwd)/finish.txt" git rebase --continue &&
-+ test_subcommand_flex git maintenance run --auto <finish.txt
++test_expect_success 'rebase runs auto maintenance once it is done' '
++ git checkout -b auto-maintenance topic &&
++ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
++ git rebase -x false main &&
++ test_subcommand_flex ! git maintenance run --auto <stop.txt &&
++ echo resolved >F2 &&
++ git add F2 &&
++ test_must_fail git rebase --continue &&
++ GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue &&
++ test_subcommand_flex git maintenance run --auto <end.txt
+'
+
test_done
@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in ins
+ test_subcommand_flex git maintenance run --auto <single.txt &&
+ GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \
+ git cherry-pick anotherpick yetanotherpick &&
++ test_subcommand_flex git maintenance run --auto <sequence.txt &&
+ grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance &&
+ test_line_count = 1 maintenance
+'
++
++test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '
++ pristine_detach initial &&
++ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
++ git cherry-pick base..anotherpick &&
++ test_subcommand_flex ! git maintenance run --auto <stop.txt &&
++ echo resolved >foo &&
++ git add foo &&
++ test_must_fail git cherry-pick --continue &&
++ GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip &&
++ test_subcommand_flex git maintenance run --auto <end.txt
++'
+
test_done
3: 9a6fc0427a ! 3: 7a353df3d9 sequencer: keep auto maintenance out of the commands a sequence spawns
@@ Metadata
Author: Thomas Bachem <[email protected]>
## Commit message ##
- sequencer: keep auto maintenance out of the commands a sequence spawns
+ sequencer: disable auto maintenance in spawned commands
- The "git commit" and "git merge" the sequencer spawns, and the git
- commands an exec runs, each start "git maintenance run --auto
- --detach", which then works in the background against the sequence
- itself. A "rerere gc" started by the commit of one "git rebase
- --continue" holds MERGE_RR.lock when the next pick needs it, and a
- repack deletes packs the sequencer still has open, which 65cda10d5b
- (sequencer: release the ODB before spawning git commit, 2026-08-12)
- had to work around.
+ The "git commit" and "git merge" the sequencer spawns run "git
+ maintenance run --auto --detach" as they finish, and so does any
+ such command an exec runs. That maintenance then works in the
+ background while the sequencer goes on with the sequence, and the
+ two get in each other's way. With rerere enabled, the maintenance
+ started by the "git commit" of a "git rebase --continue" runs
+ "rerere gc", which can still hold MERGE_RR.lock when the next pick
+ conflicts. The rebase then dies with "Unable to create
+ '.../MERGE_RR.lock': File exists" instead of stopping for the user
+ to resolve the conflict. And a repack can delete a pack the
+ sequencer still has open, which 65cda10d5b (sequencer: release the
+ ODB before spawning git commit, 2026-08-12) works around.
- The loose objects a sequence creates wait for the run at its end that
- the previous commit added. Whether a sequence can be long enough to
- suffer from them before that remains to be seen. Pass
- maintenance.auto=false and gc.auto=0 to the spawned commands through
- GIT_CONFIG_PARAMETERS, which the shell of an exec command hands on to
- whatever it runs, appended after the user's own -c settings so that
- ours win, and built once per run. A command the user runs while the
- sequence is stopped, like "git commit --amend" at an edit, is not the
- sequencer's to control and still runs maintenance.
+ Pass maintenance.auto=false to these commands through
+ GIT_CONFIG_PARAMETERS, as "git -c" would. We build the value once
+ from the one we inherited and append our setting after the user's
+ own -c settings so that it wins. The environment also reaches
+ everything the command spawns in turn, so a git command run from an
+ exec is covered as well. The sequencer also spawns "git stash", "git
+ reset" and "git notes", which never run auto maintenance.
+
+ With the previous commit, rebase, cherry-pick and revert run auto
+ maintenance once when they are done, so a sequence now runs it
+ exactly once, at the end. A sequence that stops for conflicts used
+ to run it at every resolution and now piles up its loose objects
+ until the end, as a sequence without conflicts always has.
+
+ A command the user runs while the sequence is stopped, like "git
+ commit --amend" at an edit, still runs auto maintenance. The
+ sequencer does not spawn it and has no say in it.
@@ sequencer.c: struct replay_ctx {
*/
unsigned have_message :1;
+ /*
-+ * The GIT_CONFIG_PARAMETERS value that keeps auto maintenance out
-+ * of the commands we spawn, built on first use.
++ * GIT_CONFIG_PARAMETERS for the commands we spawn, with auto
++ * maintenance turned off. Built on first use.
+ */
-+ struct strbuf config_parameters;
++ char *config_parameters;
};
struct replay_ctx* replay_ctx_new(void)
-@@ sequencer.c: struct replay_ctx* replay_ctx_new(void)
-
- strbuf_init(&ctx->current_fixups, 0);
- strbuf_init(&ctx->message, 0);
-+ strbuf_init(&ctx->config_parameters, 0);
-
- return ctx;
- }
@@ sequencer.c: static void replay_ctx_release(struct replay_ctx *ctx)
{
strbuf_release(&ctx->current_fixups); strbuf_release(&ctx->message);
-+ strbuf_release(&ctx->config_parameters);
++ free(ctx->config_parameters);
}
void replay_opts_release(struct replay_opts *opts)
@@ sequencer.c: static int run_command_silent_on_success(struct child_process *cmd)
}
+/*
-+ * A sequence runs auto maintenance once it is done, not from every command -+ * it spawns along the way: their background "rerere gc" or repack would -+ * race the sequencer for locks and files it still holds.
++ * Don't let the commands we spawn run auto maintenance. It would race ++ * us for MERGE_RR.lock or delete packs we still have open. Our caller ++ * runs it once the sequence is done.
+ */
+static void disable_auto_maintenance(struct replay_opts *opts,
+ struct child_process *cmd)
+{
-+ struct strbuf *params = &opts->ctx->config_parameters;
-+
-+ if (!params->len) {
++ if (!opts->ctx->config_parameters) {
+ const char *old = getenv(CONFIG_DATA_ENVIRONMENT);
++ struct strbuf buf = STRBUF_INIT;
+
+ if (old && *old)
-+ strbuf_addstr(params, old);
-+ git_config_append_parameter(params, "maintenance.auto", "false");
-+ git_config_append_parameter(params, "gc.auto", "0");
++ strbuf_addstr(&buf, old);
++ git_config_append_parameter(&buf, "maintenance.auto", "false");
++ opts->ctx->config_parameters = strbuf_detach(&buf, NULL);
+ }
-+ strvec_pushf(&cmd->env, "%s=%s", CONFIG_DATA_ENVIRONMENT, params->buf);
++ strvec_pushf(&cmd->env, "%s=%s", CONFIG_DATA_ENVIRONMENT,
++ opts->ctx->config_parameters);
+}
+
/*
@@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay
/*
## t/t3418-rebase-continue.sh ##
-@@ t/t3418-rebase-continue.sh: test_expect_success 'rebase runs auto maintenance at its end' '
- test_subcommand_flex git maintenance run --auto <finish.txt
- '
-
-+test_expect_success 'rebase spawns no auto maintenance before its end' '
-+ git checkout -b two-conflicts topic &&
-+ test_commit F2-again F2 222 &&
-+ test_must_fail git rebase -x "git commit --allow-empty -m exec" main &&
-+ echo resolved >F2 &&
-+ git add F2 &&
+@@ t/t3418-rebase-continue.sh: test_orig_head --merge
+ test_expect_success 'rebase runs auto maintenance once it is done' '
+ git checkout -b auto-maintenance topic &&
+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
+- git rebase -x false main &&
++ git rebase -x "git commit --allow-empty -m exec && false" main &&
+ test_subcommand_flex ! git maintenance run --auto <stop.txt &&
+ echo resolved >F2 &&
+ git add F2 &&
+- test_must_fail git rebase --continue &&
+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \
+ git rebase --continue &&
+ test_subcommand_flex git commit <mid.txt &&
+ test_subcommand_flex ! git maintenance run --auto <mid.txt &&
-+ echo resolved >F2 &&
-+ git add F2 &&
-+ GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue &&
+ GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue &&
+- test_subcommand_flex git maintenance run --auto <end.txt
+ test_subcommand_flex git maintenance run --auto <end.txt &&
+ grep "\"child_start\".*\"maintenance\"" end.txt >maintenance &&
+ test_line_count = 1 maintenance
-+'
-+
+ '
+
test_done
## t/t3510-cherry-pick-sequence.sh ##
-@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'cherry-pick runs auto maintenance once it is done' '
- test_line_count = 1 maintenance
- '
-
-+test_expect_success 'cherry-pick spawns no auto maintenance before it is done' '
-+ pristine_detach initial &&
-+ test_must_fail git cherry-pick base..anotherpick &&
-+ echo resolved >foo &&
-+ git add foo &&
+@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in insn sheet are optional' ' +
+ test_expect_success 'cherry-pick runs auto maintenance once it is done' '
+ pristine_detach base &&
+- GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked &&
++ GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick --edit picked &&
++ test_subcommand_flex git commit <single.txt &&
+ test_subcommand_flex git maintenance run --auto <single.txt &&
++ grep "\"child_start\".*\"maintenance\"" single.txt >maintenance &&
++ test_line_count = 1 maintenance &&
+ GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \
+ git cherry-pick anotherpick yetanotherpick &&
+ test_subcommand_flex git maintenance run --auto <sequence.txt &&
+@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i
+ test_subcommand_flex ! git maintenance run --auto <stop.txt &&
+ echo resolved >foo &&
+ git add foo &&
+- test_must_fail git cherry-pick --continue &&
+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \
+ git cherry-pick --continue &&
+ test_subcommand_flex git commit <mid.txt &&
+ test_subcommand_flex ! git maintenance run --auto <mid.txt &&
-+ echo d >foo &&
-+ git add foo &&
-+ GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --continue &&
-+ test_subcommand_flex git commit <end.txt &&
+ GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip &&
+- test_subcommand_flex git maintenance run --auto <end.txt
++ test_subcommand_flex git maintenance run --auto <end.txt &&
+ grep "\"child_start\".*\"maintenance\"" end.txt >maintenance &&
+ test_line_count = 1 maintenance
-+'
-+
+ '
+
test_done
Signature · 1 line
gitgitgadget
PATCH v3 1/3 config: add git_config_append_parameter()
From: Thomas Bachem <[email protected]>
"git -c key=value" passes its settings on to the git commands it spawns through the environment variable GIT_CONFIG_PARAMETERS. The value is a space separated list of 'key'='value' pairs with both sides single quoted, which git_config_from_parameters() reads back in the child. The only place we write such an entry is git_config_push_split_parameter(), and it writes straight into our own environment.
Split the formatting out into git_config_append_parameter(), which appends one entry to a strbuf, so that we can build such a value for a child's environment without repeating the quoting. The sequencer will use it in a later commit to pass settings to the commands it spawns.
--- config.c | 20 +++++++++++++------- config.h | 13 +++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-)
config.c +13 -7
@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; } +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value) +{ +if (env->len) +strbuf_addch (env,' ' ); +sq_quote_buf (env, key); +strbuf_addch (env,'=' ); +if (value) +sq_quote_buf (env, value); +} +static void git_config_push_split_parameter (const char *key,const char *value) {struct strbuf env =STRBUF_INIT ;const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); -if (old && *old) { +if (old && *old)strbuf_addstr (&env, old); -strbuf_addch (&env,' ' ); - } -sq_quote_buf (&env, key); -strbuf_addch (&env,'=' ); -if (value) -sq_quote_buf (&env, value); +git_config_append_parameter (&env, key, value);setenv (CONFIG_DATA_ENVIRONMENT , env.buf,1 );strbuf_release (&env); }
config.h +13 -0
@@ -22,6 +22,7 @@*/ struct object_id ; +struct strbuf ;/* git_config_parse_key() returns these negated: */ #define CONFIG_INVALID_KEY 1
@@ -186,6 +187,18 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name, enum config_scope scope);void git_config_push_parameter (const char *text);void git_config_push_env (const char *spec); + +/* +* Append a "-c key=value" setting to a GIT_CONFIG_PARAMETERS value in +* `env`. The variable carries such settings from a git process to the +* git commands it spawns, as a space separated list of 'key'='value' +* pairs with both sides single quoted, which git_config_from_parameters() +* reads back. A NULL `value` appends 'key'= with nothing after the equals +* sign, which stands for a boolean true, like "-c key" on the command +* line. +*/ +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value);int git_config_from_parameters (config_fn_t fn,void *data);/*
Signature · 1 line
gitgitgadget
PATCH v3 2/3 rebase, cherry-pick, revert: run auto maintenance when done
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
"git commit", "git merge", "git fetch" and "git am" run "git maintenance run --auto" when they are done, and so does the apply backend of "git rebase". That repacks the loose objects they wrote once there are enough of them, expires old rerere entries and does whatever other housekeeping is due.
The merge backend of "git rebase", "git cherry-pick" and "git revert" do not. They create their commits in process, so auto maintenance runs only when they spawn a command that runs it on its own. That is the "git commit" for a resolved conflict or an edited message, the "git merge" that "--rebase-merges" spawns for an octopus merge, a strategy other than ort or any strategy option, and whatever an exec runs. A sequence that needs none of these never runs auto maintenance. One that stops for conflicts runs it after each resolution, in the middle of the sequence.
Run it once when the sequence is done, like the apply backend does.
The apply backend leaves that to builtin/rebase.c: "git am" skips auto maintenance in rebasing mode, and finish_rebase() runs it once the patches are applied. Do the same for the sequencer, from builtin/rebase.c and builtin/revert.c, because the sequencer itself has no single place where every sequence ends. A sequence of several commits ends inside pick_commits(). A single cherry-pick or revert never creates the sequencer's state directory and returns to its caller as soon as its commit is made. "--continue" and "--skip" have entry points of their own. Nothing but those two builtins starts or continues a sequence, so that is where we run auto maintenance. run_specific_rebase() runs it for the merge backend once the sequencer has returned successfully and removed its state directory, which it keeps while the rebase is stopped. run_sequencer() runs it for cherry-pick and revert when a pick, a "--continue" or a "--skip" returns successfully.
For the user, a sequence that never stops now runs auto maintenance once when it is done, where it never ran it before. That is the same "git maintenance run --auto --detach" as after "git commit": it detaches into the background by default and does nothing unless one of its tasks is due. The runs from the commands a sequence spawns stay for now. The next commit removes them, so that a sequence runs auto maintenance exactly once.
--- builtin/rebase.c | 13 ++++++++++--- builtin/revert.c | 19 ++++++++++++------- t/t3418-rebase-continue.sh | 12 ++++++++++++ t/t3510-cherry-pick-sequence.sh | 23 +++++++++++++++++++++++ 4 files changed, 57 insertions(+), 10 deletions(-)
builtin/rebase.c +10 -3
@@ -762,9 +762,16 @@ static int run_specific_rebase(struct rebase_options *opts)if (opts->dont_finish_rebase) ;/* do nothing */ -else if (opts->type ==REBASE_MERGE ) - ;/* merge backend cleans up after itself */ -else if (status ==0 ) { +else if (opts->type ==REBASE_MERGE ) { +int quiet = !(opts->flags & (REBASE_NO_QUIET |REBASE_VERBOSE )); + +/* +* The sequencer cleans up after itself. Its state directory +* is gone once it is done, and stays while it is stopped. +*/ +if (status ==0 && !is_directory (opts->state_dir)) +run_auto_maintenance (the_repository, quiet); + }else if (status ==0 ) {if (!file_exists (state_dir_path ("stopped-sha" , opts)))finish_rebase (opts); }else if (status ==2 ) {
builtin/revert.c +12 -7
@@ -8,6 +8,7 @@#include "gettext.h" #include "revision.h" #include "rerere.h" +#include "run-command.h" #include "sequencer.h" #include "branch.h"
@@ -116,7 +117,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,const char *strategy = &sentinel_value;const char *gpg_sign = &sentinel_value;enum empty_action empty_opt =EMPTY_COMMIT_UNSPECIFIED ; -int cmd =0 ; +int cmd =0 , ret;struct option base_options[] = {OPT_CMDMODE (0 ,"quit" , &cmd,N_ ("end revert or cherry-pick sequence" ),'q' ),OPT_CMDMODE (0 ,"continue" , &cmd,N_ ("resume revert or cherry-pick sequence" ),'c' ),
@@ -264,18 +265,22 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,free (options);if (cmd =='q' ) { -int ret =sequencer_remove_state (opts); + ret =sequencer_remove_state (opts);if (!ret)remove_branch_state (the_repository,0 );return ret; } -if (cmd =='c' ) -return sequencer_continue (the_repository, opts);if (cmd =='a' )return sequencer_rollback (the_repository, opts); -if (cmd =='s' ) -return sequencer_skip (the_repository, opts); -return sequencer_pick_revisions (the_repository, opts); +if (cmd =='c' ) + ret =sequencer_continue (the_repository, opts); +else if (cmd =='s' ) + ret =sequencer_skip (the_repository, opts); +else + ret =sequencer_pick_revisions (the_repository, opts); +if (!ret) +run_auto_maintenance (the_repository, opts->quiet); +return ret; } int cmd_revert(int argc,
t/t3418-rebase-continue.sh +12 -0
@@ -395,4 +395,16 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance once it is done' ' + git checkout -b auto-maintenance topic && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ + git rebase -x false main && + test_subcommand_flex ! git maintenance run --auto <stop.txt && + echo resolved >F2 && + git add F2 && + test_must_fail git rebase --continue && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt +' + test_done
t/t3510-cherry-pick-sequence.sh +23 -0
@@ -721,4 +721,27 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_line_count = 4 commits ' +test_expect_success 'cherry-pick runs auto maintenance once it is done' ' + pristine_detach base && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + test_subcommand_flex git maintenance run --auto <single.txt && + GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ + git cherry-pick anotherpick yetanotherpick && + test_subcommand_flex git maintenance run --auto <sequence.txt && + grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance && + test_line_count = 1 maintenance +' + +test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' ' + pristine_detach initial && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ + git cherry-pick base..anotherpick && + test_subcommand_flex ! git maintenance run --auto <stop.txt && + echo resolved >foo && + git add foo && + test_must_fail git cherry-pick --continue && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && + test_subcommand_flex git maintenance run --auto <end.txt +' + test_done
Signature · 1 line
gitgitgadget
PATCH v3 3/3 sequencer: disable auto maintenance in spawned commands
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
The "git commit" and "git merge" the sequencer spawns run "git maintenance run --auto --detach" as they finish, and so does any such command an exec runs. That maintenance then works in the background while the sequencer goes on with the sequence, and the two get in each other's way. With rerere enabled, the maintenance started by the "git commit" of a "git rebase --continue" runs "rerere gc", which can still hold MERGE_RR.lock when the next pick conflicts. The rebase then dies with "Unable to create '.../MERGE_RR.lock': File exists" instead of stopping for the user to resolve the conflict. And a repack can delete a pack the sequencer still has open, which 65cda10d5b (sequencer: release the ODB before spawning git commit, 2026-08-12) works around.
Pass maintenance.auto=false to these commands through GIT_CONFIG_PARAMETERS, as "git -c" would. We build the value once from the one we inherited and append our setting after the user's own -c settings so that it wins. The environment also reaches everything the command spawns in turn, so a git command run from an exec is covered as well. The sequencer also spawns "git stash", "git reset" and "git notes", which never run auto maintenance.
With the previous commit, rebase, cherry-pick and revert run auto maintenance once when they are done, so a sequence now runs it exactly once, at the end. A sequence that stops for conflicts used to run it at every resolution and now piles up its loose objects until the end, as a sequence without conflicts always has.
A command the user runs while the sequence is stopped, like "git commit --amend" at an edit, still runs auto maintenance. The sequencer does not spawn it and has no say in it.
--- sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 11 +++++++--- t/t3510-cherry-pick-sequence.sh | 14 +++++++++--- 3 files changed, 54 insertions(+), 9 deletions(-)
sequencer.c +35 -3
@@ -234,6 +234,11 @@ struct replay_ctx {* Whether message contains a commit message. */ unsigned have_message :1; +/* +* GIT_CONFIG_PARAMETERS for the commands we spawn, with auto +* maintenance turned off. Built on first use. +*/ +char *config_parameters; };struct replay_ctx *replay_ctx_new (void )
@@ -407,6 +412,7 @@ static void replay_ctx_release(struct replay_ctx *ctx) {strbuf_release (&ctx->current_fixups);strbuf_release (&ctx->message); +free (ctx->config_parameters); }void replay_opts_release (struct replay_opts *opts)
@@ -1107,6 +1113,27 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* Don't let the commands we spawn run auto maintenance. It would race +* us for MERGE_RR.lock or delete packs we still have open. Our caller +* runs it once the sequence is done. +*/ +static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +if (!opts->ctx->config_parameters) { +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); +struct strbuf buf =STRBUF_INIT ; + +if (old && *old) +strbuf_addstr (&buf, old); +git_config_append_parameter (&buf,"maintenance.auto" ,"false" ); + opts->ctx->config_parameters =strbuf_detach (&buf,NULL ); + } +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , + opts->ctx->config_parameters); +} +/* * If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original
@@ -1148,6 +1175,7 @@ static int run_git_commit(const char *defmsg, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );
@@ -3924,16 +3952,18 @@ static int error_failed_squash(struct repository *r,return error_with_patch (r, commit, subject, subject_len, opts,1 ,1 ); } -static int do_exec (struct repository *r,const char *command_line,int quiet) +static int do_exec (struct repository *r,const char *command_line, +struct replay_opts *opts) {struct child_process cmd =CHILD_PROCESS_INIT ;int dirty, status; -if (!quiet) +if (!opts->quiet)fprintf (stderr,_ ("Executing: %s\n" ), command_line); cmd.use_shell =1 ;strvec_push (&cmd.args, command_line);strvec_push (&cmd.env,"GIT_CHERRY_PICK_HELP" ); +disable_auto_maintenance (opts, &cmd); status =run_command (&cmd);/* force re-reading of the cache */
@@ -4342,6 +4372,7 @@ static int do_merge(struct repository *r, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
@@ -5158,7 +5189,7 @@ static int pick_commits(struct repository *r,if (!opts->verbose)term_clear_line (); *end_of_arg ='\0' ; - res =do_exec (r, arg, opts->quiet); + res =do_exec (r, arg, opts); *end_of_arg = saved;if (res) {
@@ -5329,6 +5360,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)return error (_ ("no cherry-pick or revert in progress" )); cmd.git_cmd =1 ; +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );/*
t/t3418-rebase-continue.sh +8 -3
@@ -398,13 +398,18 @@ test_orig_head --merge test_expect_success 'rebase runs auto maintenance once it is done' ' git checkout -b auto-maintenance topic && test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ - git rebase -x false main && + git rebase -x "git commit --allow-empty -m exec && false" main && test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >F2 && git add F2 && - test_must_fail git rebase --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
t/t3510-cherry-pick-sequence.sh +11 -3
@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_expect_success 'cherry-pick runs auto maintenance once it is done' ' pristine_detach base && - GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick --edit picked && + test_subcommand_flex git commit <single.txt && test_subcommand_flex git maintenance run --auto <single.txt && + grep "\"child_start\".*\"maintenance\"" single.txt >maintenance && + test_line_count = 1 maintenance && GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ git cherry-pick anotherpick yetanotherpick && test_subcommand_flex git maintenance run --auto <sequence.txt &&
@@ -739,9 +742,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >foo && git add foo && - test_must_fail git cherry-pick --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git cherry-pick --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
Signature · 1 line
gitgitgadget
Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence
In reply to Thomas Bachem via GitGitGadgetQuoted 15 lines · Thomas Bachem via GitGitGadget
Changes since v2:
* Auto maintenance now runs from
builtin/rebase.candbuiltin/revert.c, once the command is done, instead of from three places inside the sequencer. That follows the apply backend, where "git am" leaves it torebase.c(Patrick, Phillip).
* gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).
*config_parametersis a char * built once withstrbuf_detach()(Junio).
* Patch 3 extends the tests of patch 2 instead of adding its own. They also assert that nothing runs before a stop, and cover a single pick with --edit and a sequence ending in --skip (Phillip).
* Commit messages rewritten: whatGIT_CONFIG_PARAMETERSis and looks like (Patrick), what patch 2 changes for the user and why the call moved (Patrick, Phillip), and the comment on the helper (Phillip).
Quoted 1 line
Based on master. Independent of the rerere lock fix in [1].
Will queue.
By the way, is it just me or are proposed log messages getting longer and longer with more irrelevant detaild these days?
If it is not just my imagination, this trend must stop.
Throw "Say the same thing in 1/N of the words used." followed by these proposed log messages to your near-by LLM, see if the output still makes sense, and adjust the value of N.
For example, I got the following from [3/3] with N==3 and I think that is far easier to understand than the original.
Sequencer-spawned commands like 'commit' and 'merge' run background auto maintenance, which interferes with ongoing operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks deleting active packs).
Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to all spawned commands. Building this value after user settings ensures it wins and propagates to child processes.
Auto maintenance now runs exactly once when the sequence completes. Commands run manually by the user while stopped are unaffected and continue to run auto maintenance normally.
Thanks.
Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence
Quoted 17 lines · Junio C Hamano
Quoted 15 lines · Thomas Bachem via GitGitGadget
Changes since v2:
* Auto maintenance now runs from
builtin/rebase.candbuiltin/revert.c, once the command is done, instead of from three places inside the sequencer. That follows the apply backend, where "git am" leaves it torebase.c(Patrick, Phillip).
* gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).
*config_parametersis a char * built once withstrbuf_detach()(Junio).
* Patch 3 extends the tests of patch 2 instead of adding its own. They also assert that nothing runs before a stop, and cover a single pick with --edit and a sequence ending in --skip (Phillip).
* Commit messages rewritten: whatGIT_CONFIG_PARAMETERSis and looks like (Patrick), what patch 2 changes for the user and why the call moved (Patrick, Phillip), and the comment on the helper (Phillip).
Quoted 6 lines
Quoted 1 line
Based on master. Independent of the rerere lock fix in [1].
Will queue.
By the way, is it just me or are proposed log messages getting longer and longer with more irrelevant detaild these days?
(sent from mobile)
Here is my impression. Six months ago, an on the surface thorough commit message would
- describe the problem
- describe the solution conceptually
- maybe the concrete code solution...
- maybe the alternatives not followed through on...
(and this is still the case overall)
That can lead to verbose commit messages. But note. There were also many things *not* included.
- What tests have been added, what they test
- That the docs have been updated (accordingly) and howso
- Maybe even benchmarks when they are not relevant?
And only in the last six months have I seen commit messages that look like they are explicitly filling in an imagined form with a dozen or so reminder/mandatory points.
(Note in the cmt msg, not after it)
The most noticable ones to me are the ones with the implied checkmarks in the last paragraph.
Those old school commit messages took all the conventions and business as usual (like adding a regression test alongside the bugfix) and didn't mention “and we are still following the project guidelines by…”
Of course, for those commit messages which look more like code-to-English descriptions, I can't even keep up and judge whether they are correct and coherent.
Quoted 1 line
[snip]
Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence
In reply to Junio C HamanoQuoted 17 lines · Junio C Hamano
Quoted 15 lines · Thomas Bachem via GitGitGadget
Changes since v2:
* Auto maintenance now runs from
builtin/rebase.candbuiltin/revert.c, once the command is done, instead of from three places inside the sequencer. That follows the apply backend, where "git am" leaves it torebase.c(Patrick, Phillip).
* gc.auto=0 dropped, maintenance.auto=false is enough (Patrick).
*config_parametersis a char * built once withstrbuf_detach()(Junio).
* Patch 3 extends the tests of patch 2 instead of adding its own. They also assert that nothing runs before a stop, and cover a single pick with --edit and a sequence ending in --skip (Phillip).
* Commit messages rewritten: whatGIT_CONFIG_PARAMETERSis and looks like (Patrick), what patch 2 changes for the user and why the call moved (Patrick, Phillip), and the comment on the helper (Phillip).
Quoted 8 lines
Quoted 1 line
Based on master. Independent of the rerere lock fix in [1].
Will queue.
By the way, is it just me or are proposed log messages getting longer and longer with more irrelevant detaild these days?
If it is not just my imagination, this trend must stop.
It's not your imagination, it's gotten quite a bit worse over the last couple weeks. I also started to push back on this trend, see [1] for example.
Thanks!
Patrick
[1]: <[email protected]>
v4 cover sequencer: leave auto maintenance to the end of a sequence
In reply to Thomas Bachem via GitGitGadgetChanges since v3:
* Commit messages condensed to about a third (Junio). 3/3 takes Junio's wording, except that the setting goes to the commit, merge and exec commands the sequencer spawns, not to all of them.
No code change.
Based on master. Independent of the rerere lock fix in [1].
[1] <[email protected]>
Thomas Bachem (3):
config: add git_config_append_parameter()
rebase, cherry-pick, revert: run auto maintenance when done
sequencer: disable auto maintenance in spawned commands
builtin/rebase.c | 13 ++++++++--- builtin/revert.c | 19 +++++++++++------ config.c | 20 +++++++++++------ config.h | 13 +++++++++++ sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 17 +++++++++++++++ t/t3510-cherry-pick-sequence.sh | 31 +++++++++++++++++++++++++++ 7 files changed, 131 insertions(+), 20 deletions(-)
base-commit: 3cb9185f65410273787f74333cc027d2ea5daada
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/2217
Range-diff vs v3:
1: 70db5ad084 ! 1: 0472fadbc5 config: add git_config_append_parameter()
@@ Metadata
## Commit message ##
config: add git_config_append_parameter()
- "git -c key=value" passes its settings on to the git commands it
- spawns through the environment variable GIT_CONFIG_PARAMETERS. The
- value is a space separated list of 'key'='value' pairs with both
- sides single quoted, which git_config_from_parameters() reads back in
- the child. The only place we write such an entry is
- git_config_push_split_parameter(), and it writes straight into our
- own environment.
+ "git -c" passes its settings to the commands it spawns through
+ GIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only
+ place that formats such an entry is git_config_push_split_parameter(),
+ which writes straight into our own environment.
Split the formatting out into git_config_append_parameter(), which
- appends one entry to a strbuf, so that we can build such a value for
- a child's environment without repeating the quoting. The sequencer
- will use it in a later commit to pass settings to the commands it
- spawns.
+ appends one entry to a strbuf, so that a caller can build the value
+ for a child's environment. The sequencer will use it in a later
+ commit.
2: 68a728c5f4 ! 2: b7b97262f2 rebase, cherry-pick, revert: run auto maintenance when done
@@ Metadata
## Commit message ##
rebase, cherry-pick, revert: run auto maintenance when done
- "git commit", "git merge", "git fetch" and "git am" run "git
- maintenance run --auto" when they are done, and so does the apply
- backend of "git rebase". That repacks the loose objects they wrote
- once there are enough of them, expires old rerere entries and does
- whatever other housekeeping is due.
-
- The merge backend of "git rebase", "git cherry-pick" and "git revert"
- do not. They create their commits in process, so auto maintenance
- runs only when they spawn a command that runs it on its own. That is
- the "git commit" for a resolved conflict or an edited message, the
- "git merge" that "--rebase-merges" spawns for an octopus merge, a
- strategy other than ort or any strategy option, and whatever an exec
- runs. A sequence that needs none of these never runs auto
- maintenance. One that stops for conflicts runs it after each
- resolution, in the middle of the sequence.
+ "git cherry-pick", "git revert" and the merge backend of "git rebase"
+ create their commits in process, so auto maintenance runs only when
+ they spawn a command that runs it, like the "git commit" for a
+ resolved conflict. A sequence thus runs it in the middle, after each
+ resolution, or never.
Run it once when the sequence is done, like the apply backend does.
- The apply backend leaves that to builtin/rebase.c: "git am" skips
- auto maintenance in rebasing mode, and finish_rebase() runs it once
- the patches are applied. Do the same for the sequencer, from
- builtin/rebase.c and builtin/revert.c, because the sequencer itself
- has no single place where every sequence ends. A sequence of several
- commits ends inside pick_commits(). A single cherry-pick or revert
- never creates the sequencer's state directory and returns to its
- caller as soon as its commit is made. "--continue" and "--skip" have
- entry points of their own. Nothing but those two builtins starts or
- continues a sequence, so that is where we run auto maintenance.
- run_specific_rebase() runs it for the merge backend once the
- sequencer has returned successfully and removed its state directory,
- which it keeps while the rebase is stopped. run_sequencer() runs it
- for cherry-pick and revert when a pick, a "--continue" or a "--skip"
- returns successfully.
-
- For the user, a sequence that never stops now runs auto maintenance
- once when it is done, where it never ran it before. That is the same
- "git maintenance run --auto --detach" as after "git commit": it
- detaches into the background by default and does nothing unless one
- of its tasks is due. The runs from the commands a sequence spawns
- stay for now. The next commit removes them, so that a sequence runs
- auto maintenance exactly once.
+ The sequencer has no single place where every sequence ends: a
+ sequence of several commits ends in pick_commits(), a single pick
+ returns as soon as its commit is made, and "--continue" and "--skip"
+ have entry points of their own. Run it from the two builtins that
+ start or continue a sequence instead: run_specific_rebase() once the
+ sequencer has returned and removed its state directory, and
+ run_sequencer() after a successful pick, "--continue" or "--skip".
3: 7a353df3d9 ! 3: 031b3bd498 sequencer: disable auto maintenance in spawned commands
@@ Metadata
## Commit message ##
sequencer: disable auto maintenance in spawned commands
- The "git commit" and "git merge" the sequencer spawns run "git
- maintenance run --auto --detach" as they finish, and so does any
- such command an exec runs. That maintenance then works in the
- background while the sequencer goes on with the sequence, and the
- two get in each other's way. With rerere enabled, the maintenance
- started by the "git commit" of a "git rebase --continue" runs
- "rerere gc", which can still hold MERGE_RR.lock when the next pick
- conflicts. The rebase then dies with "Unable to create
- '.../MERGE_RR.lock': File exists" instead of stopping for the user
- to resolve the conflict. And a repack can delete a pack the
- sequencer still has open, which 65cda10d5b (sequencer: release the
- ODB before spawning git commit, 2026-08-12) works around.
+ Sequencer-spawned commands like 'commit' and 'merge' run
+ background auto maintenance, which interferes with ongoing
+ operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks
+ deleting active packs).
- Pass maintenance.auto=false to these commands through
- GIT_CONFIG_PARAMETERS, as "git -c" would. We build the value once
- from the one we inherited and append our setting after the user's
- own -c settings so that it wins. The environment also reaches
- everything the command spawns in turn, so a git command run from an
- exec is covered as well. The sequencer also spawns "git stash", "git
- reset" and "git notes", which never run auto maintenance.
+ Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the
+ spawned commit, merge and exec commands. Appending it after the
+ user's own settings ensures it wins, and the environment reaches
+ whatever they spawn in turn.
- With the previous commit, rebase, cherry-pick and revert run auto
- maintenance once when they are done, so a sequence now runs it
- exactly once, at the end. A sequence that stops for conflicts used
- to run it at every resolution and now piles up its loose objects
- until the end, as a sequence without conflicts always has.
-
- A command the user runs while the sequence is stopped, like "git
- commit --amend" at an edit, still runs auto maintenance. The
- sequencer does not spawn it and has no say in it.
+ Auto maintenance now runs exactly once when the sequence
+ completes. Commands run manually by the user while stopped are
+ unaffected and continue to run auto maintenance normally.
Signature · 1 line
gitgitgadget
PATCH v4 1/3 config: add git_config_append_parameter()
From: Thomas Bachem <[email protected]>
"git -c" passes its settings to the commands it spawns through GIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only place that formats such an entry is git_config_push_split_parameter(), which writes straight into our own environment.
Split the formatting out into git_config_append_parameter(), which appends one entry to a strbuf, so that a caller can build the value for a child's environment. The sequencer will use it in a later commit.
--- config.c | 20 +++++++++++++------- config.h | 13 +++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-)
config.c +13 -7
@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; } +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value) +{ +if (env->len) +strbuf_addch (env,' ' ); +sq_quote_buf (env, key); +strbuf_addch (env,'=' ); +if (value) +sq_quote_buf (env, value); +} +static void git_config_push_split_parameter (const char *key,const char *value) {struct strbuf env =STRBUF_INIT ;const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); -if (old && *old) { +if (old && *old)strbuf_addstr (&env, old); -strbuf_addch (&env,' ' ); - } -sq_quote_buf (&env, key); -strbuf_addch (&env,'=' ); -if (value) -sq_quote_buf (&env, value); +git_config_append_parameter (&env, key, value);setenv (CONFIG_DATA_ENVIRONMENT , env.buf,1 );strbuf_release (&env); }
config.h +13 -0
@@ -22,6 +22,7 @@*/ struct object_id ; +struct strbuf ;/* git_config_parse_key() returns these negated: */ #define CONFIG_INVALID_KEY 1
@@ -186,6 +187,18 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name, enum config_scope scope);void git_config_push_parameter (const char *text);void git_config_push_env (const char *spec); + +/* +* Append a "-c key=value" setting to a GIT_CONFIG_PARAMETERS value in +* `env`. The variable carries such settings from a git process to the +* git commands it spawns, as a space separated list of 'key'='value' +* pairs with both sides single quoted, which git_config_from_parameters() +* reads back. A NULL `value` appends 'key'= with nothing after the equals +* sign, which stands for a boolean true, like "-c key" on the command +* line. +*/ +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value);int git_config_from_parameters (config_fn_t fn,void *data);/*
Signature · 1 line
gitgitgadget
PATCH v4 2/3 rebase, cherry-pick, revert: run auto maintenance when done
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
"git cherry-pick", "git revert" and the merge backend of "git rebase" create their commits in process, so auto maintenance runs only when they spawn a command that runs it, like the "git commit" for a resolved conflict. A sequence thus runs it in the middle, after each resolution, or never.
Run it once when the sequence is done, like the apply backend does.
The sequencer has no single place where every sequence ends: a sequence of several commits ends in pick_commits(), a single pick returns as soon as its commit is made, and "--continue" and "--skip" have entry points of their own. Run it from the two builtins that start or continue a sequence instead: run_specific_rebase() once the sequencer has returned and removed its state directory, and run_sequencer() after a successful pick, "--continue" or "--skip".
--- builtin/rebase.c | 13 ++++++++++--- builtin/revert.c | 19 ++++++++++++------- t/t3418-rebase-continue.sh | 12 ++++++++++++ t/t3510-cherry-pick-sequence.sh | 23 +++++++++++++++++++++++ 4 files changed, 57 insertions(+), 10 deletions(-)
builtin/rebase.c +10 -3
@@ -762,9 +762,16 @@ static int run_specific_rebase(struct rebase_options *opts)if (opts->dont_finish_rebase) ;/* do nothing */ -else if (opts->type ==REBASE_MERGE ) - ;/* merge backend cleans up after itself */ -else if (status ==0 ) { +else if (opts->type ==REBASE_MERGE ) { +int quiet = !(opts->flags & (REBASE_NO_QUIET |REBASE_VERBOSE )); + +/* +* The sequencer cleans up after itself. Its state directory +* is gone once it is done, and stays while it is stopped. +*/ +if (status ==0 && !is_directory (opts->state_dir)) +run_auto_maintenance (the_repository, quiet); + }else if (status ==0 ) {if (!file_exists (state_dir_path ("stopped-sha" , opts)))finish_rebase (opts); }else if (status ==2 ) {
builtin/revert.c +12 -7
@@ -8,6 +8,7 @@#include "gettext.h" #include "revision.h" #include "rerere.h" +#include "run-command.h" #include "sequencer.h" #include "branch.h"
@@ -116,7 +117,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,const char *strategy = &sentinel_value;const char *gpg_sign = &sentinel_value;enum empty_action empty_opt =EMPTY_COMMIT_UNSPECIFIED ; -int cmd =0 ; +int cmd =0 , ret;struct option base_options[] = {OPT_CMDMODE (0 ,"quit" , &cmd,N_ ("end revert or cherry-pick sequence" ),'q' ),OPT_CMDMODE (0 ,"continue" , &cmd,N_ ("resume revert or cherry-pick sequence" ),'c' ),
@@ -264,18 +265,22 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,free (options);if (cmd =='q' ) { -int ret =sequencer_remove_state (opts); + ret =sequencer_remove_state (opts);if (!ret)remove_branch_state (the_repository,0 );return ret; } -if (cmd =='c' ) -return sequencer_continue (the_repository, opts);if (cmd =='a' )return sequencer_rollback (the_repository, opts); -if (cmd =='s' ) -return sequencer_skip (the_repository, opts); -return sequencer_pick_revisions (the_repository, opts); +if (cmd =='c' ) + ret =sequencer_continue (the_repository, opts); +else if (cmd =='s' ) + ret =sequencer_skip (the_repository, opts); +else + ret =sequencer_pick_revisions (the_repository, opts); +if (!ret) +run_auto_maintenance (the_repository, opts->quiet); +return ret; } int cmd_revert(int argc,
t/t3418-rebase-continue.sh +12 -0
@@ -395,4 +395,16 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance once it is done' ' + git checkout -b auto-maintenance topic && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ + git rebase -x false main && + test_subcommand_flex ! git maintenance run --auto <stop.txt && + echo resolved >F2 && + git add F2 && + test_must_fail git rebase --continue && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt +' + test_done
t/t3510-cherry-pick-sequence.sh +23 -0
@@ -721,4 +721,27 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_line_count = 4 commits ' +test_expect_success 'cherry-pick runs auto maintenance once it is done' ' + pristine_detach base && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + test_subcommand_flex git maintenance run --auto <single.txt && + GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ + git cherry-pick anotherpick yetanotherpick && + test_subcommand_flex git maintenance run --auto <sequence.txt && + grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance && + test_line_count = 1 maintenance +' + +test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' ' + pristine_detach initial && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ + git cherry-pick base..anotherpick && + test_subcommand_flex ! git maintenance run --auto <stop.txt && + echo resolved >foo && + git add foo && + test_must_fail git cherry-pick --continue && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && + test_subcommand_flex git maintenance run --auto <end.txt +' + test_done
Signature · 1 line
gitgitgadget
PATCH v4 3/3 sequencer: disable auto maintenance in spawned commands
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
Sequencer-spawned commands like 'commit' and 'merge' run background auto maintenance, which interferes with ongoing operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks deleting active packs).
Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the spawned commit, merge and exec commands. Appending it after the user's own settings ensures it wins, and the environment reaches whatever they spawn in turn.
Auto maintenance now runs exactly once when the sequence completes. Commands run manually by the user while stopped are unaffected and continue to run auto maintenance normally.
--- sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 11 +++++++--- t/t3510-cherry-pick-sequence.sh | 14 +++++++++--- 3 files changed, 54 insertions(+), 9 deletions(-)
sequencer.c +35 -3
@@ -234,6 +234,11 @@ struct replay_ctx {* Whether message contains a commit message. */ unsigned have_message :1; +/* +* GIT_CONFIG_PARAMETERS for the commands we spawn, with auto +* maintenance turned off. Built on first use. +*/ +char *config_parameters; };struct replay_ctx *replay_ctx_new (void )
@@ -407,6 +412,7 @@ static void replay_ctx_release(struct replay_ctx *ctx) {strbuf_release (&ctx->current_fixups);strbuf_release (&ctx->message); +free (ctx->config_parameters); }void replay_opts_release (struct replay_opts *opts)
@@ -1107,6 +1113,27 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* Don't let the commands we spawn run auto maintenance. It would race +* us for MERGE_RR.lock or delete packs we still have open. Our caller +* runs it once the sequence is done. +*/ +static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +if (!opts->ctx->config_parameters) { +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); +struct strbuf buf =STRBUF_INIT ; + +if (old && *old) +strbuf_addstr (&buf, old); +git_config_append_parameter (&buf,"maintenance.auto" ,"false" ); + opts->ctx->config_parameters =strbuf_detach (&buf,NULL ); + } +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , + opts->ctx->config_parameters); +} +/* * If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original
@@ -1148,6 +1175,7 @@ static int run_git_commit(const char *defmsg, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );
@@ -3924,16 +3952,18 @@ static int error_failed_squash(struct repository *r,return error_with_patch (r, commit, subject, subject_len, opts,1 ,1 ); } -static int do_exec (struct repository *r,const char *command_line,int quiet) +static int do_exec (struct repository *r,const char *command_line, +struct replay_opts *opts) {struct child_process cmd =CHILD_PROCESS_INIT ;int dirty, status; -if (!quiet) +if (!opts->quiet)fprintf (stderr,_ ("Executing: %s\n" ), command_line); cmd.use_shell =1 ;strvec_push (&cmd.args, command_line);strvec_push (&cmd.env,"GIT_CHERRY_PICK_HELP" ); +disable_auto_maintenance (opts, &cmd); status =run_command (&cmd);/* force re-reading of the cache */
@@ -4342,6 +4372,7 @@ static int do_merge(struct repository *r, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
@@ -5158,7 +5189,7 @@ static int pick_commits(struct repository *r,if (!opts->verbose)term_clear_line (); *end_of_arg ='\0' ; - res =do_exec (r, arg, opts->quiet); + res =do_exec (r, arg, opts); *end_of_arg = saved;if (res) {
@@ -5329,6 +5360,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)return error (_ ("no cherry-pick or revert in progress" )); cmd.git_cmd =1 ; +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );/*
t/t3418-rebase-continue.sh +8 -3
@@ -398,13 +398,18 @@ test_orig_head --merge test_expect_success 'rebase runs auto maintenance once it is done' ' git checkout -b auto-maintenance topic && test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ - git rebase -x false main && + git rebase -x "git commit --allow-empty -m exec && false" main && test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >F2 && git add F2 && - test_must_fail git rebase --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
t/t3510-cherry-pick-sequence.sh +11 -3
@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_expect_success 'cherry-pick runs auto maintenance once it is done' ' pristine_detach base && - GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick --edit picked && + test_subcommand_flex git commit <single.txt && test_subcommand_flex git maintenance run --auto <single.txt && + grep "\"child_start\".*\"maintenance\"" single.txt >maintenance && + test_line_count = 1 maintenance && GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ git cherry-pick anotherpick yetanotherpick && test_subcommand_flex git maintenance run --auto <sequence.txt &&
@@ -739,9 +742,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >foo && git add foo && - test_must_fail git cherry-pick --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git cherry-pick --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
Signature · 1 line
gitgitgadget
Re: [PATCH v4 3/3] sequencer: disable auto maintenance in spawned commands
Hi Thomas
Quoted 6 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
Sequencer-spawned commands like 'commit' and 'merge' run background auto maintenance, which interferes with ongoing operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks deleting active packs).
This is much more concise, but still sounds a bit strange to me. I'd suggest
When the sequencer spawns "git commit", or "git merge", those commands
run "git maintenance --auto" in the background which can interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock or repacks deleting active packs).
Quoted 8 lines
Pass maintenance.auto=false via
GIT_CONFIG_PARAMETERSto the spawned commit, merge and exec commands. Appending it after the user's own settings ensures it wins, and the environment reaches whatever they spawn in turn.Auto maintenance now runs exactly once when the sequence completes. Commands run manually by the user while stopped are unaffected and continue to run auto maintenance normally.
Good, and the implementation changes look correct.
Quoted 6 lines
t/t3418-rebase-continue.sh +0
-0@@ -398,13 +398,18 @@ test_orig_head --merge test_expect_success 'rebase runs auto maintenance once it is done' '
t/t3418-rebase-continue.sh test_orig_head --merge · line 406
Quoted 10 lines
t/t3418-rebase-continue.sh +3
-2git checkout -b auto-maintenance topic && test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ - git rebase -x false main && + git rebase -x "git commit --allow-empty -m exec && false" main && test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >F2 && git add F2 && - test_must_fail git rebase --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue &&
What's this trying to check - there wasn't a conflict so commit_staged_changes() will error out without trying to commit anything. This series is looking pretty good now. Just to let you know I'll be off the list from tomorrow until the middle of next week so it will be a few days before I look at any new versions of this patch.
Thanks
Phillip
Quoted 44 lines
t/t3418-rebase-continue.sh +5
-1+ test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_donet/t3510-cherry-pick-sequence.sh +11
-3@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_expect_success 'cherry-pick runs auto maintenance once it is done' ' pristine_detach base && - GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick --edit picked && + test_subcommand_flex git commit <single.txt && test_subcommand_flex git maintenance run --auto <single.txt && + grep "\"child_start\".*\"maintenance\"" single.txt >maintenance && + test_line_count = 1 maintenance && GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ git cherry-pick anotherpick yetanotherpick && test_subcommand_flex git maintenance run --auto <sequence.txt &&@@ -739,9 +742,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >foo && git add foo && - test_must_fail git cherry-pick --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git cherry-pick --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
Re: [PATCH v3 0/3] sequencer: leave auto maintenance to the end of a sequence
In reply to Junio C HamanoHi Junio,
Quoted 2 lines · Junio C Hamano
For example, I got the following from [3/3] with N==3 and I think that is far easier to understand than the original.
It is. I took your text for 3/3 with one correction: it says the setting goes to all spawned commands, but I only pass it to commit, merge and exec. The sequencer also spawns stash, reset and notes, and those never run auto maintenance.
I shortened 1/3 and 2/3 to match and sent v4. The code is unchanged.
Thanks,
Thomas
Re: [PATCH v4 1/3] config: add git_config_append_parameter()
In reply to Thomas Bachem via GitGitGadgetQuoted 11 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
"git -c" passes its settings to the commands it spawns through
GIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only place that formats such an entry isgit_config_push_split_parameter(), which writes straight into our own environment.Split the formatting out into
git_config_append_parameter(), which appends one entry to a strbuf, so that a caller can build the value for a child's environment. The sequencer will use it in a later commit.
Thanks, this commit message is much better now.
Quoted 8 lines
config.h +0
-0@@ -186,6 +187,18 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name, enum config_scope scope);void git_config_push_parameter (const char *text);void git_config_push_env (const char *spec);
config.h int git_config_from_blob_oid(config_fn_t fn, const char *name, · line 199
Quoted 10 lines
config.h +10
-0+ +/* +* Append a "-c key=value" setting to a GIT_CONFIG_PARAMETERS value in +* `env`. The variable carries such settings from a git process to the +* git commands it spawns, as a space separated list of 'key'='value' +* pairs with both sides single quoted, which git_config_from_parameters() +* reads back. A NULL `value` appends 'key'= with nothing after the equals +* sign, which stands for a boolean true, like "-c key" on the command +* line. +*/
Nit: this is not necessarily specific to "-c key=value", and your later patches in fact add sites where that is not the source. Proposal:
Append a config option to the buffer that can be exported via the GIT_CONFIG_PARAMETERS environment variable, which allows us to propagate configuration across Git processes. The format of the variable is a space-separated list of quoted "'<key>'='<value>'" pairs.
Patrick
Re: [PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done
In reply to Thomas Bachem via GitGitGadgetQuoted 7 lines · Thomas Bachem via GitGitGadget
From: Thomas Bachem <[email protected]>
"git cherry-pick", "git revert" and the merge backend of "git rebase" create their commits in process, so auto maintenance runs only when they spawn a command that runs it, like the "git commit" for a resolved conflict. A sequence thus runs it in the middle, after each resolution, or never.
This paragraph still doesn't make a lot of sense. How about:
Commands that use the sequencer with the "merge" backend, like git-cherry-pick(1) or git-rebase(1) with "--merge", create their commits in-process. Consequently, these commands typically don't execute auto-maintenance at all. The only exception is when a conflict happens, as the user would have to manually commit the result via git-commit(1), and that command triggers auto-maintenance for us.
In contrast to that, the "apply" backend of the sequencer _does_ run auto-maintenance after it has processed the sequence of commits. And this is a sensible thing to do: after all, we may just have written lots of objects, so chances are high that we have something to clean up now.
Adapt users of the "merge" backend to do the same.
Unfortunately, there is no single exit point for this backend where we could add a call to run_auto_maintenance(). While one might expect that we could simply trigger auto-maintenance in pick_commits() and call it a day, a single pick as it is performed by e.g. git-revert(1) never executes that function. So instead, manually trigger auto-maintenance at several sites.
This last paragraph though...
Quoted 9 lines
Run it once when the sequence is done, like the apply backend does.
The sequencer has no single place where every sequence ends: a sequence of several commits ends in
pick_commits(), a single pick returns as soon as its commit is made, and "--continue" and "--skip" have entry points of their own. Run it from the two builtins that start or continue a sequence instead:run_specific_rebase()once the sequencer has returned and removed its state directory, andrun_sequencer()after a successful pick, "--continue" or "--skip".
... is still kind of dubious. As far as I can see, almost everything does end up in pick_commits() eventually:
- git-revert(1) does via run_sequencer(), which calls sequencer_pick_revisions(), and that calls pick_commits().
- git-cherry-pick(1) does via the same call chain.
- git-rebase(1) does so via do_interactive_rebase(), which calls complete_action(), and that function calls pick_commits(). Or alternatively via sequencer_continue(), which again calls it.
- Skipping commits via "--skip" eventually ends up in sequencer_continue(), and that calls pick_commits().
The only exception that I could spot is when we abort the sequencer. But I'd rather have us call auto-maintenance when pick_commits() is done and when we abort rather than having every user of the sequencer do it manually.
Or am I missing something here?
Patrick
Re: [PATCH v4 3/3] sequencer: disable auto maintenance in spawned commands
In reply to Phillip WoodHi Phillip,
Quoted 6 lines · Phillip Wood
This is much more concise, but still sounds a bit strange to me. I'd suggest
When the sequencer spawns "git commit", or "git merge", those commands run "git maintenance --auto" in the background which can interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock or repacks deleting active packs).
I'll take that.
Quoted 3 lines
What's this trying to check - there wasn't a conflict so
commit_staged_changes()will error out without trying to commit anything.
There is one. In this script topic and main both add F2, so the pick conflicts and the rebase stops before it gets to the exec. The "--continue" then spawns "git commit" for the resolution, which is what I look for in mid.txt, and only then runs the exec, which fails and stops the rebase a second time. Without that line the check for no maintenance run right below it would also pass if nothing had been spawned at all. I'll add a comment to the test.
Thanks,
Thomas
Re: [PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done
In reply to Patrick SteinhardtHi Patrick,
Quoted 8 lines · Patrick Steinhardt
Nit: this is not necessarily specific to "-c key=value", and your later patches in fact add sites where that is not the source. Proposal:
Append a config option to the buffer that can be exported via the
GIT_CONFIG_PARAMETERSenvironment variable, which allows us to propagate configuration across Git processes. The format of the variable is a space-separated list of quoted "'<key>'='<value>'" pairs.
Taken. I'll keep one sentence after it on what a NULL value does, since the function accepts one: it appends 'key'= with nothing after the equals sign, which git reads back as true.
Thanks,
Thomas
Re: [PATCH v4 1/3] config: add git_config_append_parameter()
In reply to Patrick SteinhardtHi Patrick,
Quoted 1 line · Patrick Steinhardt
This paragraph still doesn't make a lot of sense. How about:
I'll take your text, with two corrections.
Quoted 3 lines
execute auto-maintenance at all. The only exception is when a conflict happens, as the user would have to manually commit the result via git-commit(1), and that command triggers auto-maintenance for us.
It's the sequencer that spawns "git commit" there, on "--continue", and it spawns one for an edited message as well. That is why the next patch has to turn maintenance off in the spawned commands.
Quoted 1 line
In contrast to that, the "apply" backend of the sequencer _does_ run
The apply backend is "git am", driven from builtin/rebase.c, so I'll say "the apply backend of git rebase".
Quoted 2 lines
... is still kind of dubious. As far as I can see, almost everything does end up in
pick_commits()eventually:
[...]
Quoted 6 lines
The only exception that I could spot is when we abort the sequencer. But I'd rather have us call auto-maintenance when
pick_commits()is done and when we abort rather than having every user of the sequencer do it manually.Or am I missing something here?
The single picks. "git cherry-pick <commit>" and "git revert <commit>" take the single_pick() branch at the top of sequencer_pick_revisions() and return from there. Their "--continue" returns from sequencer_continue() through continue_single_pick() when there is no todo file, and their "--skip" returns from sequencer_skip() right after skip_single_pick(). None of them gets to pick_commits(). For rebase you're right, complete_action() and sequencer_continue() both end up there.
So inside the sequencer the call would go to the end of pick_commits() and to those three returns, plus the aborts if you want them there. "git rebase --abort" already runs it from finish_rebase(), so that would be cherry-pick and revert only. The two builtins are the sequencer's only callers, which is why I moved it to them, and Phillip preferred that too, for the single pick paths. Both work for me, say which and I'll reroll. I'll name the functions above in the message whichever you pick.
Thanks,
Thomas
v5 cover sequencer: leave auto maintenance to the end of a sequence
In reply to Thomas Bachem via GitGitGadgetChanges since v4:
* 2/3 takes Patrick's wording, with two corrections: the sequencer itself spawns the "git commit" for a resolved conflict, and the apply backend belongs to "git rebase", not to the sequencer.
* 3/3 opens with Phillip's sentence.
* The header comment of git_config_append_parameter() is Patrick's, plus one sentence on a NULL value.
* Both tests got a comment on which picks conflict and where the sequence stops (Phillip).
The code is unchanged.
Patrick, my answer to your question on 2/3 went out under the 1/3 subject by mistake [1]. The single picks are another exception: a "git cherry-pick <commit>" or "git revert <commit>" never reaches pick_commits(), and neither does its "--continue" or "--skip". So inside the sequencer the call would go to the end of pick_commits() and to those three places, plus the aborts if you want them. I kept it in the two builtins, which Phillip preferred, and 2/3 now says why. Say if you'd rather have it in the sequencer and I'll move it.
Based on master. Independent of the rerere series in [2].
[1] <CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com>
[2] <[email protected]>
Thomas Bachem (3):
config: add git_config_append_parameter()
rebase, cherry-pick, revert: run auto maintenance when done
sequencer: disable auto maintenance in spawned commands
builtin/rebase.c | 13 ++++++++--- builtin/revert.c | 19 +++++++++++------ config.c | 20 +++++++++++------ config.h | 12 +++++++++++ sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 20 +++++++++++++++++ t/t3510-cherry-pick-sequence.sh | 33 ++++++++++++++++++++++++++++ 7 files changed, 135 insertions(+), 20 deletions(-)
base-commit: 3cb9185f65410273787f74333cc027d2ea5daada
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/2217
Range-diff vs v4:
1: 0472fadbc5 ! 1: 724baf2789 config: add git_config_append_parameter()
@@ config.h: int git_config_from_blob_oid(config_fn_t fn, const char *name,
void git_config_push_env(const char *spec);
+
+/*
-+ * Append a "-c key=value" setting to a GIT_CONFIG_PARAMETERS value in -+ * env. The variable carries such settings from a git process to the -+ * git commands it spawns, as a space separated list of 'key'='value' -+ * pairs with both sides single quoted, which git_config_from_parameters() -+ * reads back. A NULL value appends 'key'= with nothing after the equals -+ * sign, which stands for a boolean true, like "-c key" on the command -+ * line.
++ * Append a config option to the buffer that can be exported via the ++ * GIT_CONFIG_PARAMETERS environment variable, which allows us to
++ * propagate configuration across Git processes. The format of the
++ * variable is a space-separated list of quoted "'<key>'='<value>'"
++ * pairs. With a NULL value, only 'key'= is appended, which git reads ++ * back as a boolean true, like "-c key" on the command line.
+ */
+void git_config_append_parameter(struct strbuf *env, const char *key,
+ const char *value);
2: b7b97262f2 ! 2: f0ec8f1f41 rebase, cherry-pick, revert: run auto maintenance when done
@@ Metadata
## Commit message ##
rebase, cherry-pick, revert: run auto maintenance when done
- "git cherry-pick", "git revert" and the merge backend of "git rebase"
- create their commits in process, so auto maintenance runs only when
- they spawn a command that runs it, like the "git commit" for a
- resolved conflict. A sequence thus runs it in the middle, after each
- resolution, or never.
+ Commands that use the sequencer with the "merge" backend, like
+ git-cherry-pick(1) or git-rebase(1) with "--merge", create their
+ commits in-process. Consequently, these commands typically don't
+ execute auto maintenance at all. Only the commands they spawn on the
+ way run it, like git-commit(1) for a resolved conflict or an edited
+ message.
- Run it once when the sequence is done, like the apply backend does.
+ In contrast to that, the "apply" backend of git-rebase(1) _does_ run
+ auto maintenance after it has processed the sequence of commits. And
+ this is a sensible thing to do: after all, we may just have written
+ lots of objects, so chances are high that we have something to clean
+ up now.
- The sequencer has no single place where every sequence ends: a
- sequence of several commits ends in pick_commits(), a single pick
- returns as soon as its commit is made, and "--continue" and "--skip"
- have entry points of their own. Run it from the two builtins that
- start or continue a sequence instead: run_specific_rebase() once the
- sequencer has returned and removed its state directory, and
- run_sequencer() after a successful pick, "--continue" or "--skip".
+ Adapt users of the "merge" backend to do the same.
+
+ The sequencer has no single exit where a call to run_auto_maintenance()
+ could go. A sequence ends in pick_commits(), but a single pick never
+ gets there: it returns from sequencer_pick_revisions() via
+ single_pick(), its "--continue" from sequencer_continue() via
+ continue_single_pick(), and its "--skip" from sequencer_skip(). So
+ call it from the sequencer's two callers instead: run_specific_rebase()
+ for the merge backend, once its state directory is gone, and
+ run_sequencer() in builtin/revert.c after a successful pick,
+ "--continue" or "--skip".
@@ t/t3418-rebase-continue.sh: test_orig_head () {
test_orig_head --merge
+test_expect_success 'rebase runs auto maintenance once it is done' '
++ # topic and main both add F2, so the pick conflicts and the rebase
++ # stops before the exec runs, and once more when the exec fails
+ git checkout -b auto-maintenance topic &&
+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
+ git rebase -x false main &&
@@ t/t3510-cherry-pick-sequence.sh: test_expect_success 'commit descriptions in ins
+'
+
+test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '
++ # both picked and anotherpick conflict on foo, so "--continue" stops
++ # once more before "--skip" ends the sequence
+ pristine_detach initial &&
+ test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
+ git cherry-pick base..anotherpick &&
3: 031b3bd498 ! 3: c51ea031ea sequencer: disable auto maintenance in spawned commands
@@ Metadata
## Commit message ##
sequencer: disable auto maintenance in spawned commands
- Sequencer-spawned commands like 'commit' and 'merge' run
- background auto maintenance, which interferes with ongoing
- operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks
- deleting active packs).
+ When the sequencer spawns "git commit" or "git merge", those commands
+ run "git maintenance run --auto" in the background, which can
+ interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock
+ or repacks deleting active packs).
Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the spawned commit, merge and exec commands. Appending it after the
@@ sequencer.c: static int continue_single_pick(struct repository *r, struct replay
## t/t3418-rebase-continue.sh ##
@@ t/t3418-rebase-continue.sh: test_orig_head --merge
+
test_expect_success 'rebase runs auto maintenance once it is done' '
+ # topic and main both add F2, so the pick conflicts and the rebase
+- # stops before the exec runs, and once more when the exec fails
++ # stops before the exec runs. "--continue" commits the resolution
++ # first, then runs the exec, which fails and stops it again.
git checkout -b auto-maintenance topic && test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
- git rebase -x false main &&
Signature · 1 line
gitgitgadget
PATCH v5 1/3 config: add git_config_append_parameter()
From: Thomas Bachem <[email protected]>
"git -c" passes its settings to the commands it spawns through GIT_CONFIG_PARAMETERS, a list of quoted 'key'='value' pairs. The only place that formats such an entry is git_config_push_split_parameter(), which writes straight into our own environment.
Split the formatting out into git_config_append_parameter(), which appends one entry to a strbuf, so that a caller can build the value for a child's environment. The sequencer will use it in a later commit.
--- config.c | 20 +++++++++++++------- config.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-)
config.c +13 -7
@@ -450,18 +450,24 @@ static int git_config_include(const char *var, const char *value,return ret; } +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value) +{ +if (env->len) +strbuf_addch (env,' ' ); +sq_quote_buf (env, key); +strbuf_addch (env,'=' ); +if (value) +sq_quote_buf (env, value); +} +static void git_config_push_split_parameter (const char *key,const char *value) {struct strbuf env =STRBUF_INIT ;const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); -if (old && *old) { +if (old && *old)strbuf_addstr (&env, old); -strbuf_addch (&env,' ' ); - } -sq_quote_buf (&env, key); -strbuf_addch (&env,'=' ); -if (value) -sq_quote_buf (&env, value); +git_config_append_parameter (&env, key, value);setenv (CONFIG_DATA_ENVIRONMENT , env.buf,1 );strbuf_release (&env); }
config.h +12 -0
@@ -22,6 +22,7 @@*/ struct object_id ; +struct strbuf ;/* git_config_parse_key() returns these negated: */ #define CONFIG_INVALID_KEY 1
@@ -186,6 +187,17 @@ int git_config_from_blob_oid(config_fn_t fn, const char *name, enum config_scope scope);void git_config_push_parameter (const char *text);void git_config_push_env (const char *spec); + +/* +* Append a config option to the buffer that can be exported via the +* GIT_CONFIG_PARAMETERS environment variable, which allows us to +* propagate configuration across Git processes. The format of the +* variable is a space-separated list of quoted "'<key>'='<value>'" +* pairs. With a NULL `value`, only 'key'= is appended, which git reads +* back as a boolean true, like "-c key" on the command line. +*/ +void git_config_append_parameter (struct strbuf *env,const char *key, +const char *value);int git_config_from_parameters (config_fn_t fn,void *data);/*
Signature · 1 line
gitgitgadget
PATCH v5 2/3 rebase, cherry-pick, revert: run auto maintenance when done
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
Commands that use the sequencer with the "merge" backend, like git-cherry-pick(1) or git-rebase(1) with "--merge", create their commits in-process. Consequently, these commands typically don't execute auto maintenance at all. Only the commands they spawn on the way run it, like git-commit(1) for a resolved conflict or an edited message.
In contrast to that, the "apply" backend of git-rebase(1) _does_ run auto maintenance after it has processed the sequence of commits. And this is a sensible thing to do: after all, we may just have written lots of objects, so chances are high that we have something to clean up now.
Adapt users of the "merge" backend to do the same.
The sequencer has no single exit where a call to run_auto_maintenance() could go. A sequence ends in pick_commits(), but a single pick never gets there: it returns from sequencer_pick_revisions() via single_pick(), its "--continue" from sequencer_continue() via continue_single_pick(), and its "--skip" from sequencer_skip(). So call it from the sequencer's two callers instead: run_specific_rebase() for the merge backend, once its state directory is gone, and run_sequencer() in builtin/revert.c after a successful pick, "--continue" or "--skip".
--- builtin/rebase.c | 13 ++++++++++--- builtin/revert.c | 19 ++++++++++++------- t/t3418-rebase-continue.sh | 14 ++++++++++++++ t/t3510-cherry-pick-sequence.sh | 25 +++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 10 deletions(-)
builtin/rebase.c +10 -3
@@ -762,9 +762,16 @@ static int run_specific_rebase(struct rebase_options *opts)if (opts->dont_finish_rebase) ;/* do nothing */ -else if (opts->type ==REBASE_MERGE ) - ;/* merge backend cleans up after itself */ -else if (status ==0 ) { +else if (opts->type ==REBASE_MERGE ) { +int quiet = !(opts->flags & (REBASE_NO_QUIET |REBASE_VERBOSE )); + +/* +* The sequencer cleans up after itself. Its state directory +* is gone once it is done, and stays while it is stopped. +*/ +if (status ==0 && !is_directory (opts->state_dir)) +run_auto_maintenance (the_repository, quiet); + }else if (status ==0 ) {if (!file_exists (state_dir_path ("stopped-sha" , opts)))finish_rebase (opts); }else if (status ==2 ) {
builtin/revert.c +12 -7
@@ -8,6 +8,7 @@#include "gettext.h" #include "revision.h" #include "rerere.h" +#include "run-command.h" #include "sequencer.h" #include "branch.h"
@@ -116,7 +117,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,const char *strategy = &sentinel_value;const char *gpg_sign = &sentinel_value;enum empty_action empty_opt =EMPTY_COMMIT_UNSPECIFIED ; -int cmd =0 ; +int cmd =0 , ret;struct option base_options[] = {OPT_CMDMODE (0 ,"quit" , &cmd,N_ ("end revert or cherry-pick sequence" ),'q' ),OPT_CMDMODE (0 ,"continue" , &cmd,N_ ("resume revert or cherry-pick sequence" ),'c' ),
@@ -264,18 +265,22 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,free (options);if (cmd =='q' ) { -int ret =sequencer_remove_state (opts); + ret =sequencer_remove_state (opts);if (!ret)remove_branch_state (the_repository,0 );return ret; } -if (cmd =='c' ) -return sequencer_continue (the_repository, opts);if (cmd =='a' )return sequencer_rollback (the_repository, opts); -if (cmd =='s' ) -return sequencer_skip (the_repository, opts); -return sequencer_pick_revisions (the_repository, opts); +if (cmd =='c' ) + ret =sequencer_continue (the_repository, opts); +else if (cmd =='s' ) + ret =sequencer_skip (the_repository, opts); +else + ret =sequencer_pick_revisions (the_repository, opts); +if (!ret) +run_auto_maintenance (the_repository, opts->quiet); +return ret; } int cmd_revert(int argc,
t/t3418-rebase-continue.sh +14 -0
@@ -395,4 +395,18 @@ test_orig_head () { test_orig_head --apply test_orig_head --merge +test_expect_success 'rebase runs auto maintenance once it is done' ' + # topic and main both add F2, so the pick conflicts and the rebase + # stops before the exec runs, and once more when the exec fails + git checkout -b auto-maintenance topic && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ + git rebase -x false main && + test_subcommand_flex ! git maintenance run --auto <stop.txt && + echo resolved >F2 && + git add F2 && + test_must_fail git rebase --continue && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && + test_subcommand_flex git maintenance run --auto <end.txt +' + test_done
t/t3510-cherry-pick-sequence.sh +25 -0
@@ -721,4 +721,29 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_line_count = 4 commits ' +test_expect_success 'cherry-pick runs auto maintenance once it is done' ' + pristine_detach base && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + test_subcommand_flex git maintenance run --auto <single.txt && + GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ + git cherry-pick anotherpick yetanotherpick && + test_subcommand_flex git maintenance run --auto <sequence.txt && + grep "\"child_start\".*\"maintenance\"" sequence.txt >maintenance && + test_line_count = 1 maintenance +' + +test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' ' + # both picked and anotherpick conflict on foo, so "--continue" stops + # once more before "--skip" ends the sequence + pristine_detach initial && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ + git cherry-pick base..anotherpick && + test_subcommand_flex ! git maintenance run --auto <stop.txt && + echo resolved >foo && + git add foo && + test_must_fail git cherry-pick --continue && + GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && + test_subcommand_flex git maintenance run --auto <end.txt +' + test_done
Signature · 1 line
gitgitgadget
PATCH v5 3/3 sequencer: disable auto maintenance in spawned commands
In reply to Thomas Bachem via GitGitGadgetFrom: Thomas Bachem <[email protected]>
When the sequencer spawns "git commit" or "git merge", those commands run "git maintenance run --auto" in the background, which can interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock or repacks deleting active packs).
Pass maintenance.auto=false via GIT_CONFIG_PARAMETERS to the spawned commit, merge and exec commands. Appending it after the user's own settings ensures it wins, and the environment reaches whatever they spawn in turn.
Auto maintenance now runs exactly once when the sequence completes. Commands run manually by the user while stopped are unaffected and continue to run auto maintenance normally.
--- sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 14 ++++++++---- t/t3510-cherry-pick-sequence.sh | 14 +++++++++--- 3 files changed, 56 insertions(+), 10 deletions(-)
sequencer.c +35 -3
@@ -234,6 +234,11 @@ struct replay_ctx {* Whether message contains a commit message. */ unsigned have_message :1; +/* +* GIT_CONFIG_PARAMETERS for the commands we spawn, with auto +* maintenance turned off. Built on first use. +*/ +char *config_parameters; };struct replay_ctx *replay_ctx_new (void )
@@ -407,6 +412,7 @@ static void replay_ctx_release(struct replay_ctx *ctx) {strbuf_release (&ctx->current_fixups);strbuf_release (&ctx->message); +free (ctx->config_parameters); }void replay_opts_release (struct replay_opts *opts)
@@ -1107,6 +1113,27 @@ static int run_command_silent_on_success(struct child_process *cmd)return rc; } +/* +* Don't let the commands we spawn run auto maintenance. It would race +* us for MERGE_RR.lock or delete packs we still have open. Our caller +* runs it once the sequence is done. +*/ +static void disable_auto_maintenance (struct replay_opts *opts, +struct child_process *cmd) +{ +if (!opts->ctx->config_parameters) { +const char *old =getenv (CONFIG_DATA_ENVIRONMENT ); +struct strbuf buf =STRBUF_INIT ; + +if (old && *old) +strbuf_addstr (&buf, old); +git_config_append_parameter (&buf,"maintenance.auto" ,"false" ); + opts->ctx->config_parameters =strbuf_detach (&buf,NULL ); + } +strvec_pushf (&cmd->env,"%s=%s" ,CONFIG_DATA_ENVIRONMENT , + opts->ctx->config_parameters); +} +/* * If we are cherry-pick, and if the merge did not result in * hand-editing, we will hit this commit and inherit the original
@@ -1148,6 +1175,7 @@ static int run_git_commit(const char *defmsg, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );
@@ -3924,16 +3952,18 @@ static int error_failed_squash(struct repository *r,return error_with_patch (r, commit, subject, subject_len, opts,1 ,1 ); } -static int do_exec (struct repository *r,const char *command_line,int quiet) +static int do_exec (struct repository *r,const char *command_line, +struct replay_opts *opts) {struct child_process cmd =CHILD_PROCESS_INIT ;int dirty, status; -if (!quiet) +if (!opts->quiet)fprintf (stderr,_ ("Executing: %s\n" ), command_line); cmd.use_shell =1 ;strvec_push (&cmd.args, command_line);strvec_push (&cmd.env,"GIT_CHERRY_PICK_HELP" ); +disable_auto_maintenance (opts, &cmd); status =run_command (&cmd);/* force re-reading of the cache */
@@ -4342,6 +4372,7 @@ static int do_merge(struct repository *r, author_date_from_env(&cmd.env));if (opts->ignore_date)strvec_push (&cmd.env,"GIT_AUTHOR_DATE=" ); +disable_auto_maintenance (opts, &cmd); cmd.git_cmd =1 ;strvec_push (&cmd.args,"merge" );
@@ -5158,7 +5189,7 @@ static int pick_commits(struct repository *r,if (!opts->verbose)term_clear_line (); *end_of_arg ='\0' ; - res =do_exec (r, arg, opts->quiet); + res =do_exec (r, arg, opts); *end_of_arg = saved;if (res) {
@@ -5329,6 +5360,7 @@ static int continue_single_pick(struct repository *r, struct replay_opts *opts)return error (_ ("no cherry-pick or revert in progress" )); cmd.git_cmd =1 ; +disable_auto_maintenance (opts, &cmd);strvec_push (&cmd.args,"commit" );/*
t/t3418-rebase-continue.sh +10 -4
@@ -397,16 +397,22 @@ test_orig_head --merge test_expect_success 'rebase runs auto maintenance once it is done' ' # topic and main both add F2, so the pick conflicts and the rebase - # stops before the exec runs, and once more when the exec fails + # stops before the exec runs. "--continue" commits the resolution + # first, then runs the exec, which fails and stops it again. git checkout -b auto-maintenance topic && test_must_fail env GIT_TRACE2_EVENT="$(pwd)/stop.txt" \ - git rebase -x false main && + git rebase -x "git commit --allow-empty -m exec && false" main && test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >F2 && git add F2 && - test_must_fail git rebase --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git rebase --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git rebase --continue && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
t/t3510-cherry-pick-sequence.sh +11 -3
@@ -723,8 +723,11 @@ test_expect_success 'commit descriptions in insn sheet are optional' ' test_expect_success 'cherry-pick runs auto maintenance once it is done' ' pristine_detach base && - GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick picked && + GIT_TRACE2_EVENT="$(pwd)/single.txt" git cherry-pick --edit picked && + test_subcommand_flex git commit <single.txt && test_subcommand_flex git maintenance run --auto <single.txt && + grep "\"child_start\".*\"maintenance\"" single.txt >maintenance && + test_line_count = 1 maintenance && GIT_TRACE2_EVENT="$(pwd)/sequence.txt" \ git cherry-pick anotherpick yetanotherpick && test_subcommand_flex git maintenance run --auto <sequence.txt &&
@@ -741,9 +744,14 @@ test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence i test_subcommand_flex ! git maintenance run --auto <stop.txt && echo resolved >foo && git add foo && - test_must_fail git cherry-pick --continue && + test_must_fail env GIT_TRACE2_EVENT="$(pwd)/mid.txt" \ + git cherry-pick --continue && + test_subcommand_flex git commit <mid.txt && + test_subcommand_flex ! git maintenance run --auto <mid.txt && GIT_TRACE2_EVENT="$(pwd)/end.txt" git cherry-pick --skip && - test_subcommand_flex git maintenance run --auto <end.txt + test_subcommand_flex git maintenance run --auto <end.txt && + grep "\"child_start\".*\"maintenance\"" end.txt >maintenance && + test_line_count = 1 maintenance ' test_done
Signature · 1 line
gitgitgadget
Re: [PATCH v4 2/3] rebase, cherry-pick, revert: run auto maintenance when done
In reply to Patrick SteinhardtHi Patrick,
Quoted 6 lines · Patrick Steinhardt
The only exception that I could spot is when we abort the sequencer. But I'd rather have us call auto-maintenance when
pick_commits()is done and when we abort rather than having every user of the sequencer do it manually.Or am I missing something here?
The single picks. "git cherry-pick <commit>" and "git revert <commit>" return from sequencer_pick_revisions() through single_pick(). Their "--continue" returns from sequencer_continue() through continue_single_pick() when there is no todo file, and their "--skip" from sequencer_skip() when there is no sequencer directory. None of the three reaches pick_commits().
The paragraph you proposed for 2/3 says it too:
Quoted 6 lines
Unfortunately, there is no single exit point for this backend where we could add a call to
run_auto_maintenance(). While one might expect that we could simply trigger auto-maintenance inpick_commits()and call it a day, a single pick as it is performed by e.g. git-revert(1) never executes that function. So instead, manually trigger auto-maintenance at several sites.
2/3 in v5 names those three returns. My answer went out under the 1/3 subject by mistake [1].
Phillip's answer when I offered the move [2]:
Quoted 3 lines
That works for we and means we don't have to sprinkle calls to
run_auto_maintenance()around to accommodate the different code paths for single and multiple picks.
So inside the sequencer the call would go to the end of pick_commits(), to those three returns, and to the aborts. "git rebase --abort" already runs it from finish_rebase(), so that leaves the cherry-pick and revert aborts. The two builtins are the sequencer's only callers, which is why I moved it there. Both work for me, say which and I'll reroll.
Thanks,
Thomas
[1] <CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com>
[2] <[email protected]>
Re: [PATCH v5 0/3] sequencer: leave auto maintenance to the end of a sequence
In reply to Thomas Bachem via GitGitGadgetHi Thomas
Quoted 10 lines · Thomas Bachem via GitGitGadget
Changes since v4:
* 2/3 takes Patrick's wording, with two corrections: the sequencer itself spawns the "git commit" for a resolved conflict, and the apply backend belongs to "git rebase", not to the sequencer.
* 3/3 opens with Phillip's sentence.
* The header comment ofgit_config_append_parameter()is Patrick's, plus one sentence on a NULL value.
* Both tests got a comment on which picks conflict and where the sequence stops (Phillip).
Thanks for adding that, it is easier to understand what the tests are doing now. This looks ready for next to me.
Thanks for working on it
Phillip
Quoted 154 lines
The code is unchanged.
Patrick, my answer to your question on 2/3 went out under the 1/3 subject by mistake [1]. The single picks are another exception: a "git cherry-pick <commit>" or "git revert <commit>" never reaches
pick_commits(), and neither does its "--continue" or "--skip". So inside the sequencer the call would go to the end ofpick_commits()and to those three places, plus the aborts if you want them. I kept it in the two builtins, which Phillip preferred, and 2/3 now says why. Say if you'd rather have it in the sequencer and I'll move it.Based on master. Independent of the rerere series in [2].
[1] <CAA0xjtoW3JfSbuBot0ANFiDEhEv1N-Di4mSd5tYfgkFEeh07Nw@mail.gmail.com>
[2] <[email protected]>
Thomas Bachem (3):
config: addgit_config_append_parameter()
rebase, cherry-pick, revert: run auto maintenance when done
sequencer: disable auto maintenance in spawned commandsbuiltin/rebase.c | 13 ++++++++--- builtin/revert.c | 19 +++++++++++------ config.c | 20 +++++++++++------ config.h | 12 +++++++++++ sequencer.c | 38 ++++++++++++++++++++++++++++++--- t/t3418-rebase-continue.sh | 20 +++++++++++++++++ t/t3510-cherry-pick-sequence.sh | 33 ++++++++++++++++++++++++++++ 7 files changed, 135 insertions(+), 20 deletions(-)base-commit:
3cb9185f65410273787f74333cc027d2ea5daada
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2217%2Fthomasbachem%2Frebase-auto-maintenance-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2217/thomasbachem/rebase-auto-maintenance-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/2217Range-diff vs v4:
1:
0472fadbc5! 1:724baf2789config: addgit_config_append_parameter()
@@config.h: int git_config_from_blob_oid(config_fn_t fn, const char *name,
voidgit_config_push_env(const char *spec);
+
+/*
-+ * Append a "-c key=value" setting to aGIT_CONFIG_PARAMETERSvalue in -+ *env. The variable carries such settings from a git process to the -+ * git commands it spawns, as a space separated list of 'key'='value' -+ * pairs with both sides single quoted, whichgit_config_from_parameters()-+ * reads back. A NULLvalueappends 'key'= with nothing after the equals -+ * sign, which stands for a boolean true, like "-c key" on the command -+ * line.
++ * Append a config option to the buffer that can be exported via the ++ *GIT_CONFIG_PARAMETERSenvironment variable, which allows us to
++ * propagate configuration across Git processes. The format of the
++ * variable is a space-separated list of quoted "'<key>'='<value>'"
++ * pairs. With a NULLvalue, only 'key'= is appended, which git reads ++ * back as a boolean true, like "-c key" on the command line.
+ */
+void git_config_append_parameter(struct strbuf *env, const char *key,
+ const char *value);
2:b7b97262f2! 2:f0ec8f1f41rebase, cherry-pick, revert: run auto maintenance when done
@@ Metadata
## Commit message ##
rebase, cherry-pick, revert: run auto maintenance when done- "git cherry-pick", "git revert" and the merge backend of "git rebase"
- create their commits in process, so auto maintenance runs only when
- they spawn a command that runs it, like the "git commit" for a
- resolved conflict. A sequence thus runs it in the middle, after each
- resolution, or never.
+ Commands that use the sequencer with the "merge" backend, like
+ git-cherry-pick(1) or git-rebase(1) with "--merge", create their
+ commits in-process. Consequently, these commands typically don't
+ execute auto maintenance at all. Only the commands they spawn on the
+ way run it, like git-commit(1) for a resolved conflict or an edited
+ message.- Run it once when the sequence is done, like the apply backend does.
+ In contrast to that, the "apply" backend of git-rebase(1) _does_ run
+ auto maintenance after it has processed the sequence of commits. And
+ this is a sensible thing to do: after all, we may just have written
+ lots of objects, so chances are high that we have something to clean
+ up now.- The sequencer has no single place where every sequence ends: a
- sequence of several commits ends inpick_commits(), a single pick
- returns as soon as its commit is made, and "--continue" and "--skip"
- have entry points of their own. Run it from the two builtins that
- start or continue a sequence instead:run_specific_rebase()once the
- sequencer has returned and removed its state directory, and
-run_sequencer()after a successful pick, "--continue" or "--skip".
+ Adapt users of the "merge" backend to do the same.
+
+ The sequencer has no single exit where a call torun_auto_maintenance()
+ could go. A sequence ends inpick_commits(), but a single pick never
+ gets there: it returns fromsequencer_pick_revisions()via
+single_pick(), its "--continue" fromsequencer_continue()via
+continue_single_pick(), and its "--skip" fromsequencer_skip(). So
+ call it from the sequencer's two callers instead:run_specific_rebase()
+ for the merge backend, once its state directory is gone, and
+run_sequencer()inbuiltin/revert.cafter a successful pick,
+ "--continue" or "--skip".Assisted-by Claude Fable 5.1Signed-off-by Thomas Bachem <[email protected]>@@
t/t3418-rebase-continue.sh:test_orig_head() {
test_orig_head--merge+test_expect_success 'rebase runs auto maintenance once it is done' '
++ # topic and main both add F2, so the pick conflicts and the rebase
++ # stops before the exec runs, and once more when the exec fails
+ git checkout -b auto-maintenance topic &&
+test_must_failenv GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
+ git rebase -x false main &&
@@t/t3510-cherry-pick-sequence.sh:test_expect_success'commit descriptions in ins
+'
+
+test_expect_success 'cherry-pick runs auto maintenance once a stopped sequence is done' '
++ # both picked and anotherpick conflict on foo, so "--continue" stops
++ # once more before "--skip" ends the sequence
+pristine_detachinitial &&
+test_must_failenv GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
+ git cherry-pick base..anotherpick &&
3:031b3bd498! 3:c51ea031easequencer: disable auto maintenance in spawned commands
@@ Metadata
## Commit message ##
sequencer: disable auto maintenance in spawned commands- Sequencer-spawned commands like 'commit' and 'merge' run
- background auto maintenance, which interferes with ongoing
- operations (e.g. 'rerere gc' holding MERGE_RR.lock or repacks
- deleting active packs).
+ When the sequencer spawns "git commit" or "git merge", those commands
+ run "git maintenance run --auto" in the background, which can
+ interfere with the sequencer (e.g. 'rerere gc' holding MERGE_RR.lock
+ or repacks deleting active packs).Pass maintenance.auto=false via
GIT_CONFIG_PARAMETERSto the spawned commit, merge and exec commands. Appending it after the
@@sequencer.c: static int continue_single_pick(struct repository *r, struct replay##
t/t3418-rebase-continue.sh##
@@t/t3418-rebase-continue.sh:test_orig_head--merge
+
test_expect_success'rebase runs auto maintenance once it is done' '
+ # topic and main both add F2, so the pick conflicts and the rebase
+- # stops before the exec runs, and once more when the exec fails
++ # stops before the exec runs. "--continue" commits the resolution
++ # first, then runs the exec, which fails and stops it again.
git checkout -b auto-maintenance topic &&test_must_failenv GIT_TRACE2_EVENT="$(pwd)/stop.txt" \
- git rebase -x false main &&
Re: [PATCH v5 0/3] sequencer: leave auto maintenance to the end of a sequence
Quoted 14 lines · Phillip Wood
Hi Thomas
Quoted 10 lines · Thomas Bachem via GitGitGadget
Changes since v4:
* 2/3 takes Patrick's wording, with two corrections: the sequencer itself spawns the "git commit" for a resolved conflict, and the apply backend belongs to "git rebase", not to the sequencer.
* 3/3 opens with Phillip's sentence.
* The header comment ofgit_config_append_parameter()is Patrick's, plus one sentence on a NULL value.
* Both tests got a comment on which picks conflict and where the sequence stops (Phillip).
Quoted 4 lines
Thanks for adding that, it is easier to understand what the tests are doing now. This looks ready for next to me.
Thanks for working on it
It's already been merged to next anyway, but agreed, this looks ready to me. Thanks!
Patrick