From: Christian Brauner <brauner@kernel.org>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
"Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH b4 2/6] shazam: ignore the user's submodule.recurse in the scratch worktree
Date: Wed, 29 Jul 2026 12:44:29 +0200 [thread overview]
Message-ID: <20260729-work-b4-scratch-worktrees-v1-2-e96995158d4a@kernel.org> (raw)
In-Reply-To: <20260729-work-b4-scratch-worktrees-v1-0-e96995158d4a@kernel.org>
With submodule.recurse=true in the user's config every apply through
git_fetch_am_into_repo() fails in a repo that carries submodules. That
covers b4 shazam and review-branch creation in the review TUI:
Magic: Preparing a sparse worktree
Error running checkout into sparse workdir
fatal: not a git repository: ../../worktrees/b4-shazam-worktree/modules/ezgb
fatal: could not reset submodule index
git gives every linked worktree its own submodule clones under
.git/worktrees/<name>/modules/ and a just-created worktree has none, so
the recursing sparse checkout dies looking for them. The b4 repo itself
is affected through its vendored patatt/liblore/ezgb submodules.
Everything b4 does in that worktree is thrown away when the call
returns, so the user's checkout conveniences have no business running
there. Let's add SCRATCH_GIT_OPTS with the two overrides a git command
in a scratch worktree needs, no submodule recursion and no gpg signing,
the same override the TUI's test applies already pass by hand. The
sparse-checkout and the checkout get it.
The fetch out of the worktree takes nothing. It runs in the user's own
repo rather than in the scratch worktree, so the user's config is the
right one there, and a recursing fetch does not trip over the missing
clones anyway.
The apply itself keeps the user's config. Its commits are the real
series and not scratch throwaways, so signing stays in force. The
replay-on-full-worktree fallback needs nothing. Neither git-am nor
git-sparse-checkout consults submodule.recurse (checked on git 2.53).
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
src/b4/__init__.py | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 8afbbab..1a883b4 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -132,6 +132,24 @@ DEVSIG_HDR = 'X-Developer-Signature'
LOREADDR = 'https://lore.kernel.org'
LINKADDR = 'https://patch.msgid.link'
+# Overrides for git commands b4 runs inside its own scratch worktrees. A fresh
+# linked worktree has no per-worktree submodule clones, so a checkout or reset
+# obeying submodule.recurse=true dies with "fatal: not a git repository:
+# .../worktrees/<wt>/modules/<name>"; and unattended commit-creating commands
+# must never gpg-sign -- signing hangs on a pinentry prompt no terminal will
+# 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
+# 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] = [
+ '-c',
+ 'submodule.recurse=false',
+ '-c',
+ 'commit.gpgsign=false',
+]
+
DEFAULT_CONFIG: ConfigDictT = {
'midmask': LOREADDR + '/all/%s',
'searchmask': LOREADDR + '/all/?x=m&q=%s',
@@ -5972,19 +5990,24 @@ def git_fetch_am_into_repo(
try:
logger.info('Magic: Preparing a sparse worktree')
ecode, out = git_run_command(
- gwt, ['sparse-checkout', 'set'], logstderr=True, rundir=gwt
+ gwt,
+ [*SCRATCH_GIT_OPTS, 'sparse-checkout', 'set'],
+ logstderr=True,
+ rundir=gwt,
)
if ecode > 0:
logger.critical('Error running sparse-checkout set')
logger.critical(out)
raise RuntimeError
ecode, out = git_run_command(
- gwt, ['checkout', '-f'], logstderr=True, rundir=gwt
+ gwt, [*SCRATCH_GIT_OPTS, 'checkout', '-f'], logstderr=True, rundir=gwt
)
if ecode > 0:
logger.critical('Error running checkout into sparse workdir')
logger.critical(out)
raise RuntimeError
+ # No SCRATCH_GIT_OPTS on the apply: its commits are the real series,
+ # not scratch throwaways, so the user's signing config stays in force.
amargs = ['am']
if am_flags:
amargs.extend(am_flags)
--
2.53.0
next prev parent reply other threads:[~2026-07-29 10:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 10:44 [PATCH b4 0/6] Keep the user's git config out of b4's scratch worktrees Christian Brauner
2026-07-29 10:44 ` [PATCH b4 1/6] git_run_command: look past -c overrides for the subcommand Christian Brauner
2026-07-29 10:44 ` Christian Brauner [this message]
2026-07-29 10:44 ` [PATCH b4 3/6] review-tui: use the shared scratch-worktree overrides for test applies Christian Brauner
2026-07-29 10:44 ` [PATCH b4 4/6] fake-am: use the scratch-worktree overrides in the staging worktree Christian Brauner
2026-07-29 10:44 ` [PATCH b4 5/6] send: use the scratch-worktree overrides when tagging a sent series Christian Brauner
2026-07-29 10:44 ` [PATCH b4 6/6] tests: exercise the scratch worktrees under submodule.recurse Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260729-work-b4-scratch-worktrees-v1-2-e96995158d4a@kernel.org \
--to=brauner@kernel.org \
--cc=konstantin@linuxfoundation.org \
--cc=tools@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.