Skip to content

git_cmd: pin git config settings that change printed output - #905

Merged
rgushchin merged 1 commit into
sashiko-dev:mainfrom
vladwing:git-show-ignore-user-format
Nov 16, 2026
Merged

rgushchin merged 1 commit into
sashiko-dev:mainfrom
vladwing:git-show-ignore-user-format

Conversation

@vladwing

Copy link
Copy Markdown
Contributor

On a machine whose git config sets format.pretty to a one-line format, sashiko review reports Fixes: and other trailers as missing when the commit has them. This PR makes the git_cmd constructors override fifteen settings that reshape git's output, format.pretty among them, so a git config file can no longer set them for the commits, diffs and branch lists sashiko reads.

The bug. get_commit_show and get_commit_message run git show without a format option, so format.pretty decides how much of the commit message comes back. With a one-line format only the subject line does, and every review stage sees a commit with no body and no trailers. Other git show and git log calls whose output is parsed or sent to a model have the same problem: the cited-commit excerpt in fixes_check and the git_show tool among them. log.date, the color settings, log.decorate, log.showSignature, log.abbrevCommit, log.showRoot, column.ui and the diff prefix settings reshape that output too.

How it was found. A local review of a kernel commit with a correct Fixes: tag, run with format.pretty set, raised a Low finding asking for that tag. Rerun with GIT_CONFIG_GLOBAL pointing at a copy of the config without format.pretty and log.date, it saw the full message and did not raise it.

The fix. The git_cmd constructors pass -c with each of the fifteen settings at its unconfigured value; for the color settings and log.decorate, whose default auto already means off on a pipe, that value is false. git_cmd already strips GIT_CONFIG_COUNT and GIT_CONFIG_PARAMETERS, so the environment cannot inject settings; settings in the config files still could. An option a call site passes itself, such as --format, still wins. Settings that run other programs, such as diff.external, are left alone.

Left for a follow-up. Five groups of settings can still change what git prints: diff.context, diff.interHunkContext and diff.renames, grep.column, i18n.logOutputEncoding, blame.*, and the notes and mailmap settings. None of them changed what the review read in the case that found this bug. I can add them to this PR if you would rather have them in one change.

Testing. Every failure below also happens on main or is in a file this PR does not touch. All of it ran on Rust 1.99.1, because the pinned 1.93.1 could not be downloaded on the test host.

  • With format.pretty and log.date set in the user's config, four existing tests fail on main and pass with this change: test_git_log and test_git_show_virtual_head in toolbox::tools_test, and both analyze_fixes tests in fixes_check.
  • Two new tests set format.pretty and log.date in a repository's config, the first with five more of the pinned settings, and check what git show prints: test_user_output_settings_do_not_change_what_git_prints through git_cmd, and test_commit_show_ignores_user_format_config through get_commit_show and get_commit_message. Both fail without the fix.
  • cargo test --all-features --no-fail-fast: everything passes except four lib tests (scan::tests::test_resolve_targets_and_build_chunks_with_header_prefetch and three worker::prefetch tests). Those four also fail on main on the test host, whose git was built without PCRE (fatal: cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE).
  • cargo fmt --check and the sign-off check pass. cargo clippy --all-targets --all-features -- -D warnings reports nothing in the two changed files, but fails on six warnings in files this PR does not touch (server.rs, bedrock.rs, related_preexisting.rs), probably lints added after Rust 1.93.
  • Local sashiko review --project sashiko on this commit: status clean, no findings, and three Low concerns, all marked pre-existing, about settings in the follow-up list above. An earlier run also flagged the commit_resolution_repo test fixture's commit, which still follows the global commit.gpgsign and core.hooksPath.

A local review on a machine whose git config sets format.pretty to a
one-line format reports Fixes: and other trailers as missing when the
commit carries them. get_commit_show and get_commit_message run a bare
git show, so the user's format.pretty decides how much of the message
comes back: with a one-line format only the subject line does, and
every stage reviews a commit with no body and no trailers. The same
holds for every other git show and git log whose output is parsed or
handed to a model, such as the cited-commit excerpt in fixes_check and
the git_show tool. log.date, the color settings, log.decorate,
log.showSignature, log.abbrevCommit, log.showRoot, column.ui and the
diff prefix settings reshape that output too.

Pin those fifteen settings with -c in the git_cmd constructors, each
at the value git uses when it is unset (false for the color settings
and log.decorate, whose default auto already means off on a pipe), so
a config file can no longer change them. git_cmd already strips
GIT_CONFIG_COUNT and GIT_CONFIG_PARAMETERS so that the environment
cannot inject settings; settings in the config files still could. An
option a call site passes itself, such as --format, still wins.
Settings that run other programs, such as diff.external, are left
alone.

With format.pretty and log.date set in the user's config, four
existing tests failed before this change and pass after it:
test_git_log and test_git_show_virtual_head in toolbox::tools_test,
and both analyze_fixes tests in fixes_check. Two new tests set those
settings in a repository's config and check what git show prints: one
through git_cmd directly, one through get_commit_show and
get_commit_message.

Fixes: ffc448e ("worker: use authentic git show output for patch context")
Fixes: c917af1 ("git: extract pure commit message without diff using get_commit_message")
Signed-off-by: Vlad Poenaru <vlad.wing@gmail.com>
@sashiko-bot

sashiko-bot Bot commented Nov 14, 2026

Copy link
Copy Markdown

Sashiko review

✓ No issues found across 1 commit.

Full review log on sashiko.sashiko.dev

@rgushchin
rgushchin merged commit 9c78829 into sashiko-dev:main Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants