Skip to contentSkip to conversation

Keep the user's git config out of b4's scratch worktrees

PATCH Applied Christian Brauner 2 participants 8 messages Jul 29 – Jul 31

lore
Share & tools
lore
#0 lore raw

cover Keep the user's git config out of b4's scratch worktrees

With submodule.recurse=true in the user's config b4 cannot apply anything in a repo that carries submodules. The scratch worktree's sparse checkout recurses, looks for the per-worktree submodule clones a just-created worktree cannot have, and dies:

fatal: not a git repository: ../../worktrees/b4-shazam-worktree/modules/ezgb
fatal: could not reset submodule index

That takes review-branch creation, b4 shazam and the TUI's test applies with it. The b4 repo itself is affected through its vendored patatt/liblore/ezgb submodules.

Everything b4 does in those worktrees is thrown away when the call returns, so they can run with overrides of their own: no submodule recursion and no gpg signing. SCRATCH_GIT_OPTS carries both, since each is inert where the other matters, and every scratch worktree switches over to it: the shazam apply, the TUI's five hand-rolled test applies, the fake-am staging worktree and the sent-tag worktree in b4 send. The commits that outlive their worktree keep the user's signing config.

---
Christian Brauner (6):
git_run_command: look past -c overrides for the subcommand
shazam: ignore the user's submodule.recurse in the scratch worktree
review-tui: use the shared scratch-worktree overrides for test applies
fake-am: use the scratch-worktree overrides in the staging worktree
send: use the scratch-worktree overrides when tagging a sent series
tests: exercise the scratch worktrees under submodule.recurse

 src/b4/__init__.py                 |  43 +++++++++--
 src/b4/ez.py                       |   8 +-
 src/b4/review_tui/_modals.py       |  44 +++++++----
 src/b4/review_tui/_tracking_app.py |  11 ++-
 src/tests/conftest.py              |  52 ++++++++++++-
 src/tests/test___init__.py         |  15 ++++
 src/tests/test_ez.py               |  45 +++++++++++-
 src/tests/test_tui_tracking.py     | 146 ++++++++++++++++++++++++++++++++++++-
 8 files changed, 332 insertions(+), 32 deletions(-)

---
base-commit: 99fe195c0aa5a88be5033f87cad22bc32d27cbfe
change-id: 20260729-work-b4-scratch-worktrees-f69cde824a95

#1 lore raw

PATCH 1/6 git_run_command: look past -c overrides for the subcommand

git_run_command() counteracts a local log.abbrevCommit by inserting --no-abbrev-commit after the subcommand, which it expects at args[0]. That holds only as long as no caller passes git-level options first.

The next patch adds a list of -c overrides that callers prefix to their arguments. With it args[0] is '-c', the fixup stops firing and nothing says so. b4 parses full shas out of git-log output in several places, so a user with log.abbrevCommit=true would get short ones back.

Skip over leading -c key=value pairs when looking for the subcommand. While we are here, stop inserting into the caller's list in place.

---
 src/b4/__init__.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
src/b4/__init__.py +7 -3
index f66d38d..8afbbab 100644
@@ -3664,9 +3664,13 @@ def git_run_command(
                 gitdir = dotgit
             cmdargs += ['--git-dir', str(gitdir)]
 
-    # counteract some potential local settings
-    if args[0] == 'log':
-        args.insert(1, '--no-abbrev-commit')
+    # counteract some potential local settings; the subcommand is not
+    # necessarily args[0] because callers may prefix -c overrides
+    subcmd = 0
+    while subcmd + 1 < len(args) and args[subcmd] == '-c':
+        subcmd += 2
+    if subcmd < len(args) and args[subcmd] == 'log':
+        args = args[: subcmd + 1] + ['--no-abbrev-commit'] + args[subcmd + 1 :]
 
     cmdargs += args
 
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/6 shazam: ignore the user's submodule.recurse in the scratch worktree

In reply to Christian Brauner

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).

---
 src/b4/__init__.py | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
src/b4/__init__.py +25 -2
index 8afbbab..1a883b4 100644
@@ -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)
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/6 review-tui: use the shared scratch-worktree overrides for test applies

In reply to Christian Brauner

The test-apply paths build the same sparse scratch worktree in five places, the four modal am probes and the take flow's cherry-pick probe. Each of them passes -c commit.gpgsign=false on the apply by hand and nothing at all on the checkout.

That checkout is the bug just fixed in git_fetch_am_into_repo(). With submodule.recurse=true the probe's checkout -f dies in any repo that carries submodules, so every test apply reported a failure that had nothing to do with the patches.

Let's switch all five sites to SCRATCH_GIT_OPTS. gpgsign means nothing to a checkout and recursion means nothing to am and cherry-pick, so the one list serves every command and the applies keep behaving as before. The per-site "# No signing" comments go with it.

---
 src/b4/review_tui/_modals.py       | 44 ++++++++++++++++++++++++--------------
 src/b4/review_tui/_tracking_app.py | 11 ++++++----
 2 files changed, 35 insertions(+), 20 deletions(-)
src/b4/review_tui/_modals.py +28 -16
index 89253bc..1d8ea4f 100644
@@ -1075,15 +1075,18 @@ class TakeConfirmScreen(ModalScreen[bool]):
             # Test apply in a temporary sparse worktree
             try:
                 with b4.git_temp_worktree(topdir, resolved_base) as gwt:
-                    ecode, out = b4.git_run_command(gwt, ['sparse-checkout', 'set'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'sparse-checkout', 'set']
+                    )
                     if ecode > 0:
                         return False, 'failed to set up worktree'
-                    ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'checkout', '-f']
+                    )
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    # 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
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'am'], stdin=ambytes
                     )
                     if ecode > 0:
                         for line in out.splitlines():
@@ -2069,15 +2072,18 @@ class RebaseScreen(ModalScreen[bool]):
         with _quiet_worker():
             try:
                 with b4.git_temp_worktree(topdir, branch) as gwt:
-                    ecode, out = b4.git_run_command(gwt, ['sparse-checkout', 'set'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'sparse-checkout', 'set']
+                    )
                     if ecode > 0:
                         return False, 'failed to set up worktree'
-                    ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'checkout', '-f']
+                    )
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    # 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
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'am'], stdin=ambytes
                     )
                     if ecode > 0:
                         for line in out.splitlines():
@@ -2342,15 +2348,18 @@ class TargetBranchScreen(ModalScreen[Optional[str]]):
         with _quiet_worker():
             try:
                 with b4.git_temp_worktree(topdir, branch) as gwt:
-                    ecode, out = b4.git_run_command(gwt, ['sparse-checkout', 'set'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'sparse-checkout', 'set']
+                    )
                     if ecode > 0:
                         return False, 'failed to set up worktree'
-                    ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'checkout', '-f']
+                    )
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    # 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
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'am'], stdin=ambytes
                     )
                     if ecode > 0:
                         for line in out.splitlines():
@@ -3059,15 +3068,18 @@ class BaseSelectionScreen(ModalScreen[Optional[str]]):
         with _quiet_worker():
             try:
                 with b4.git_temp_worktree(topdir, base) as gwt:
-                    ecode, out = b4.git_run_command(gwt, ['sparse-checkout', 'set'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'sparse-checkout', 'set']
+                    )
                     if ecode > 0:
                         return False, 'failed to set up worktree'
-                    ecode, out = b4.git_run_command(gwt, ['checkout', '-f'])
+                    ecode, out = b4.git_run_command(
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'checkout', '-f']
+                    )
                     if ecode > 0:
                         return False, 'failed to checkout base'
-                    # 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
+                        gwt, [*b4.SCRATCH_GIT_OPTS, 'am'], stdin=ambytes
                     )
                     if ecode > 0:
                         # Extract just the "Patch failed" line
src/b4/review_tui/_tracking_app.py +7 -4
index 2b29dc1..efdfeaf 100644
@@ -3370,11 +3370,15 @@ class TrackingApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[Optional[str]]):
             with b4.git_temp_worktree(topdir, target_head) as gwt:
                 # Set up sparse checkout for minimal disk usage
                 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.warning('Could not set up sparse checkout: %s', out.strip())
-                ecode, out = b4.git_run_command(gwt, ['checkout', '-f'], logstderr=True)
+                ecode, out = b4.git_run_command(
+                    gwt, [*b4.SCRATCH_GIT_OPTS, 'checkout', '-f'], logstderr=True
+                )
                 if ecode != 0:
                     logger.warning(
                         'Could not checkout sparse worktree: %s', out.strip()
@@ -3382,8 +3386,7 @@ class TrackingApp(LoreNodeShutdownMixin, CheckRunnerMixin, App[Optional[str]]):
 
                 # Try cherry-picking the commits
                 gitargs = [
-                    '-c',
-                    'commit.gpgsign=false',
+                    *b4.SCRATCH_GIT_OPTS,
                     'cherry-pick',
                     f'{base_commit}..{series_tip}',
                 ]
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/6 fake-am: use the scratch-worktree overrides in the staging worktree

In reply to Christian Brauner

make_fake_am_range() has a throwaway worktree of its own. It stages the blobs the series expects to find, commits that tree, resets onto it and ams the patches on top to get a commit range b4 can diff against. b4 diff goes through it, and so do the review TUI's range-diff and its three-way merge prep.

The reset recurses like any other. A series that touches a submodule puts a gitlink into the synthesized tree, and the reset then dies in the same fresh worktree with no submodule clones. The am is worse. Those commits exist to compute a diff range and nothing ever references them, but git still reaches for the user's signing key, and with a card that is not plugged in the whole range fails.

Both get SCRATCH_GIT_OPTS.

---
 src/b4/__init__.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
src/b4/__init__.py +4 -2
index 1a883b4..d418cee 100644
@@ -1449,13 +1449,15 @@ class LoreSeries:
                 return None, None
             start_commit = out.strip()
             logger.debug('start_commit=%s', start_commit)
-            git_run_command(dfn, ['reset', '--hard', start_commit])
+            git_run_command(dfn, [*SCRATCH_GIT_OPTS, 'reset', '--hard', start_commit])
 
             ifh = io.BytesIO()
             save_git_am_mbox(msgs, ifh)
             ambytes = ifh.getvalue()
 
-            ecode, out = git_run_command(dfn, ['am'], stdin=ambytes, logstderr=True)
+            ecode, out = git_run_command(
+                dfn, [*SCRATCH_GIT_OPTS, 'am'], stdin=ambytes, logstderr=True
+            )
             if ecode > 0:
                 logger.critical('ERROR: Could not fake-am version v%s', self.revision)
                 return None, None
Signature · 1 line
2.53.0
#5 lore raw

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

In reply to Christian Brauner

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.

---
 src/b4/__init__.py | 2 +-
 src/b4/ez.py       | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
src/b4/__init__.py +1 -1
index d418cee..bc4a797 100644
@@ -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] = [
src/b4/ez.py +6 -2
index 268d783..ec922e4 100644
@@ -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:
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/6 tests: exercise the scratch worktrees under submodule.recurse

In reply to Christian Brauner

An active but unpopulated submodule reproduces the recursing-checkout
fatal: a gitlink and .gitmodules in the tree plus a configured url, and no clone anywhere. That is what every fresh linked worktree sees. The fixture is built with plumbing so nothing is signed and master can be advanced in place, and submodule.recurse goes on only once it is done.

git_fetch_am_into_repo() runs end to end that way, and so do the four modal test-apply probes, the take flow's cherry-pick probe and reroll()'s sent-tag worktree, which has to come back with the tag it was asked for.

The fake-am test drives a series that bumps a gitlink, because that is what puts a submodule into the synthesized tree, and poisons gpg on top of it, so the reset and the am are covered at once.

The git_run_command() fixup gets its own test. With log.abbrevCommit=true and a -c override in front of the subcommand the sha has to come back in full.

---
 src/tests/conftest.py          |  52 ++++++++++++++-
 src/tests/test___init__.py     |  15 +++++
 src/tests/test_ez.py           |  45 ++++++++++++-
 src/tests/test_tui_tracking.py | 146 ++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 255 insertions(+), 3 deletions(-)
src/tests/conftest.py +51 -1
index 48b2573..aa6dbc8 100644
@@ -2,7 +2,7 @@ import copy
 import os
 import pathlib
 import sys
-from typing import Generator
+from typing import Callable, Generator
 
 import pytest
 
@@ -49,6 +49,56 @@ def sampledir(request: pytest.FixtureRequest) -> str:
     return os.path.join(request.path.parent, 'samples')
 
 
[email protected](scope='function')
+def add_unpopulated_submodule() -> Callable[..., str]:
+    """Factory: advance master with an active but unpopulated submodule.
+
+    A gitlink and .gitmodules in the tree plus a configured url is all it
+    takes: no clone exists anywhere, which is exactly what any fresh linked
+    worktree sees, and a git command recursing into submodules there dies with
+    "fatal: not a git repository: .../worktrees/<wt>/modules/<name>". Built
+    with plumbing so nothing is signed and master can be advanced in place.
+    Callers flip submodule.recurse on only once their own fixtures are built --
+    this setup would trip over it too. Returns the sha the gitlink points at.
+    """
+
+    def _add(gitdir: str, name: str = 'sub') -> str:
+        ecode, head = b4.git_run_command(gitdir, ['rev-parse', 'master'])
+        assert ecode == 0
+        gitlink = head.strip()
+        gm = pathlib.Path(gitdir) / '.gitmodules'
+        gm.write_text(f'[submodule "{name}"]\n\tpath = {name}\n\turl = ./{name}\n')
+        ecode, _ = b4.git_run_command(gitdir, ['add', '.gitmodules'])
+        assert ecode == 0
+        ecode, _ = b4.git_run_command(
+            gitdir,
+            ['update-index', '--add', '--cacheinfo', f'160000,{gitlink},{name}'],
+        )
+        assert ecode == 0
+        ecode, tree = b4.git_run_command(gitdir, ['write-tree'])
+        assert ecode == 0
+        ecode, commit = b4.git_run_command(
+            gitdir,
+            ['commit-tree', tree.strip(), '-p', 'master'],
+            stdin=f'add {name} gitlink\n'.encode(),
+        )
+        assert ecode == 0
+        ecode, _ = b4.git_run_command(
+            gitdir, ['update-ref', 'refs/heads/master', commit.strip()]
+        )
+        assert ecode == 0
+        ecode, _ = b4.git_run_command(gitdir, ['reset', '--hard', 'master'])
+        assert ecode == 0
+        ecode, entry = b4.git_run_command(gitdir, ['ls-tree', 'master', name])
+        assert ecode == 0 and entry.startswith('160000 commit'), (
+            f'gitlink did not land in master: {entry!r}'
+        )
+        b4.git_set_config(gitdir, f'submodule.{name}.url', f'./{name}')
+        return gitlink
+
+    return _add
+
+
 @pytest.fixture(scope='function')
 def gitdir(
     request: pytest.FixtureRequest, tmp_path: pathlib.Path
src/tests/test___init__.py +15 -0
index e66f993..b02ed12 100644
@@ -1219,3 +1219,18 @@ def test_edit_in_editor_normalizes_crlf(
     monkeypatch.setenv('GIT_EDITOR', 'true')
     out = b4.edit_in_editor(b'line one\r\nline two\r\rlast\r\n', filehint='reply.eml')
     assert out == b'line one\nline two\n\nlast\n'
+
+
+def test_git_run_command_log_fixup_looks_past_option_prefix(gitdir: str) -> None:
+    """``--no-abbrev-commit`` must survive a leading ``-c`` override.
+
+    git_run_command counteracts log.abbrevCommit by injecting the flag after
+    the subcommand -- which it can only find by skipping the ``-c key=value``
+    pairs callers prefix (see SCRATCH_GIT_OPTS).
+    """
+    b4.git_set_config(gitdir, 'log.abbrevCommit', 'true')
+    ecode, out = b4.git_run_command(gitdir, ['-c', 'gc.auto=0', 'log', '-1'])
+    assert ecode == 0
+    assert out.startswith('commit '), out
+    sha = out.split('\n', 1)[0].split()[1]
+    assert len(sha) == 40, f'log abbreviated the sha despite the fixup: {sha}'
src/tests/test_ez.py +44 -1

54 lines not on this page · raw message

src/tests/test_tui_tracking.py +145 -1

161 lines not on this page · raw message

Signature · 1 line
2.53.0
#7 lore raw
In reply to Christian Brauner
Quoted 8 lines · Christian Brauner

Keep the user's git config out of b4's scratch worktrees

With submodule.recurse=true in the user's config b4 cannot apply anything in a repo that carries submodules. The scratch worktree's sparse checkout recurses, looks for the per-worktree submodule clones a just-created worktree cannot have, and dies:

[...]

Applied, thanks!

[1/6] git_run_command: look past -c overrides for the subcommand

      commit: 97e09203a66f7849500cd0258d83864c15535461
[2/6] shazam: ignore the user's submodule.recurse in the scratch worktree
      commit: ea34dcdac92304fa422ee90ab9b541931d7e527e
[3/6] review-tui: use the shared scratch-worktree overrides for test applies
      commit: c9a21b8111ddd79485a4e8d787ff43158ee49aff
[4/6] fake-am: use the scratch-worktree overrides in the staging worktree
      commit: cecec5d1844fdbcc4cfa90e56b10f6358eb4948d
[5/6] send: use the scratch-worktree overrides when tagging a sent series
      commit: 0abeddbb46c2f86b052de4e31816912246bd9d23
[6/6] tests: exercise the scratch worktrees under submodule.recurse
      commit: 6991ac96a05cd410c1734a0cd15307481f11860b

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>