[PATCH b4 5/6] send: use the scratch-worktree overrides when tagging a sent series

Christian Brauner <[email protected]> Wed, 29 Jul 2026 12:44:32 +0200
Newsgroups org.kernel.linux.tools
Message-ID <[email protected]>
When the cover lives in a commit, which is the default cover strategy,
reroll() builds the sent tag out of a scratch worktree: sparse
checkout, cherry-pick the series onto the base, fetch the result back.
That checkout is the one fixed in git_fetch_am_into_repo() and it dies
the same way with submodule.recurse=true.

Nothing tells the user. The whole block sits under a try that logs
"Error tagging the revision" and carries on, so b4 send finishes
normally and the sent tag for the revision is simply never created.

The cherry-pick keeps the user's signing config. Its commits are what
the tag points at, so they outlive the worktree.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/b4/__init__.py | 2 +-
 src/b4/ez.py       | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index d418cee..bc4a797 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -140,7 +140,7 @@ LINKADDR = 'https://patch.msgid.link'
 # answer. Each override is inert where the other matters, so the one list
 # serves every scratch-worktree git command. Commits that outlive the worktree
 # are the exception and keep the user's signing config: the real apply in
-# git_fetch_am_into_repo. Fetching *out of* a
+# git_fetch_am_into_repo, the cherry-pick in ez.reroll(). Fetching *out of* a
 # worktree takes nothing -- that one runs in the user's repo, not in the
 # scratch, so the user's config still governs it.
 SCRATCH_GIT_OPTS: List[str] = [
diff --git a/src/b4/ez.py b/src/b4/ez.py
index 268d783..ec922e4 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -3302,19 +3302,23 @@ def reroll(
                 with b4.git_temp_worktree(topdir, base_commit) as gwt:
                     logger.debug('Preparing a sparse worktree')
                     ecode, out = b4.git_run_command(
-                        gwt, ['sparse-checkout', 'set'], logstderr=True
+                        gwt,
+                        [*b4.SCRATCH_GIT_OPTS, 'sparse-checkout', 'set'],
+                        logstderr=True,
                     )
                     if ecode > 0:
                         logger.critical('Error running sparse-checkout set')
                         logger.critical(out)
                         raise RuntimeError
                     ecode, out = b4.git_run_command(
-                        gwt, ['checkout', '-f'], logstderr=True
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'checkout', '-f'], logstderr=True
                     )
                     if ecode > 0:
                         logger.critical('Error running checkout into sparse workdir')
                         logger.critical(out)
                         raise RuntimeError
+                    # No SCRATCH_GIT_OPTS: the sent tag points at these commits,
+                    # so the user's signing config stays in force.
                     gitargs = ['cherry-pick', f'{start_commit}..{end_commit}']
                     ecode, out = b4.git_run_command(gwt, gitargs, logstderr=True)
                     if ecode > 0:

-- 
2.53.0