[PATCH b4 1/6] git_run_command: look past -c overrides for the subcommand
Christian Brauner <[email protected]> Wed, 29 Jul 2026 12:44:28 +0200
| Newsgroups | org.kernel.linux.tools |
|---|---|
| Message-ID | <[email protected]> |
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) <[email protected]> --- 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