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 1/6] git_run_command: look past -c overrides for the subcommand
Date: Wed, 29 Jul 2026 12:44:28 +0200 [thread overview]
Message-ID: <20260729-work-b4-scratch-worktrees-v1-1-e96995158d4a@kernel.org> (raw)
In-Reply-To: <20260729-work-b4-scratch-worktrees-v1-0-e96995158d4a@kernel.org>
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.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
src/b4/__init__.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index f66d38d..8afbbab 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -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
--
2.53.0
next prev parent reply other threads:[~2026-07-29 10:44 UTC|newest]
Thread overview: 8+ 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 ` Christian Brauner [this message]
2026-07-29 10:44 ` [PATCH b4 2/6] shazam: ignore the user's submodule.recurse in the scratch worktree Christian Brauner
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
2026-07-31 5:08 ` [PATCH b4 0/6] Keep the user's git config out of b4's scratch worktrees Konstantin Ryabitsev
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-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox