[PATCH b4 1/2] review-tui: don't gpg-sign throwaway test-apply commits

Christian Brauner <[email protected]> Thu, 23 Jul 2026 10:33:35 +0200
Newsgroups org.kernel.linux.tools
Message-ID <[email protected]>
The take/rebase/target/base modals check whether a series applies
cleanly by running a real git-am into a temporary worktree and rebase
additionally probes with a cherry-pick. The four modal probes run from
worker threads while the TUI keeps the terminal.

With commit.gpgsign=true and pinentry-curses git tries to sign every
probe commit. pinentry then pops up on the tty that Textual owns in raw
mode. The TUI repaints over the PIN dialog and its input reader swallows
the keystrokes and so gpg never gets the PIN and the apply hangs. With a
card-backed key this reproduces on every take.

The probe commits are discarded together with the temporary worktree
so signing them is pure waste. Let's pass -c commit.gpgsign=false to all
five probes. The rebase cherry-pick runs under suspend() and so cannot
deadlock. But its commits are just as throwaway. Real applies (checkout,
take, rebase, merge) are unaffected. They run with the TUI suspended,
where pinentry works, and keep signing per the user's configuration.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/b4/review_tui/_modals.py       | 20 ++++++++++++++++----
 src/b4/review_tui/_tracking_app.py |  7 ++++++-
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/b4/review_tui/_modals.py b/src/b4/review_tui/_modals.py
index 51e6b4e..0a0c943 100644
--- a/src/b4/review_tui/_modals.py
+++ b/src/b4/review_tui/_modals.py
@@ -1066,7 +1066,10 @@ class TakeConfirmScreen(ModalScreen[bool]):
                     ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    ecode, out = b4.git_run_command(gwt, ['am'], stdin=ambytes)
+                    # No signing: gpg would prompt while the TUI owns the tty.
+                    ecode, out = b4.git_run_command(
+                        gwt, ['-c', 'commit.gpgsign=false', 'am'], stdin=ambytes
+                    )
                     if ecode > 0:
                         for line in out.splitlines():
                             if line.startswith('Patch failed at '):
@@ -2057,7 +2060,10 @@ class RebaseScreen(ModalScreen[bool]):
                     ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    ecode, out = b4.git_run_command(gwt, ['am'], stdin=ambytes)
+                    # No signing: gpg would prompt while the TUI owns the tty.
+                    ecode, out = b4.git_run_command(
+                        gwt, ['-c', 'commit.gpgsign=false', 'am'], stdin=ambytes
+                    )
                     if ecode > 0:
                         for line in out.splitlines():
                             if line.startswith('Patch failed at '):
@@ -2327,7 +2333,10 @@ class TargetBranchScreen(ModalScreen[Optional[str]]):
                     ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    ecode, out = b4.git_run_command(gwt, ['am'], stdin=ambytes)
+                    # No signing: gpg would prompt while the TUI owns the tty.
+                    ecode, out = b4.git_run_command(
+                        gwt, ['-c', 'commit.gpgsign=false', 'am'], stdin=ambytes
+                    )
                     if ecode > 0:
                         for line in out.splitlines():
                             if line.startswith('Patch failed at '):
@@ -3044,7 +3053,10 @@ class BaseSelectionScreen(ModalScreen[Optional[str]]):
                     ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    ecode, out = b4.git_run_command(gwt, ['am'], stdin=ambytes)
+                    # No signing: gpg would prompt while the TUI owns the tty.
+                    ecode, out = b4.git_run_command(
+                        gwt, ['-c', 'commit.gpgsign=false', 'am'], stdin=ambytes
+                    )
                     if ecode > 0:
                         # Extract just the "Patch failed" line
                         for line in out.splitlines():
diff --git a/src/b4/review_tui/_tracking_app.py b/src/b4/review_tui/_tracking_app.py
index 7e7f142..594ecef 100644
--- a/src/b4/review_tui/_tracking_app.py
+++ b/src/b4/review_tui/_tracking_app.py
@@ -3310,7 +3310,12 @@ class TrackingApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[Optional[str]]):
                     )
 
                 # Try cherry-picking the commits
-                gitargs = ['cherry-pick', f'{base_commit}..{series_tip}']
+                gitargs = [
+                    '-c',
+                    'commit.gpgsign=false',
+                    'cherry-pick',
+                    f'{base_commit}..{series_tip}',
+                ]
                 ecode, out = b4.git_run_command(gwt, gitargs, logstderr=True)
                 if ecode != 0:
                     logger.warning('Series does not apply cleanly to %s', target_branch)

-- 
2.53.0