Skip to content

fix: count files whose names ls-files would trim, quote, or blame would parse as options - #1

Merged
Nitjsefnie merged 1 commit into
perf-blamefrom
nul-safe-paths
Nov 12, 2026
Merged

Nitjsefnie merged 1 commit into
perf-blamefrom
nul-safe-paths

Conversation

@Nitjsefnie

@Nitjsefnie Nitjsefnie commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

git fame dropped files whose names start with -, start or end with a space, or that Git C-quotes, so its totals undercounted any repository holding one; this lists files NUL-separated and passes -- before the path to git blame.

Related Issues and Pull Requests

Relates to Nitjsefnie/gh-widgets#285

Changes

  • gitfame/_gitfame.py _get_auth_stats: git ls-files -z and git grep -I --name-only -z replace the newline split and .strip(), which trimmed a leading space from the first listed name and a trailing space from the last, and kept Git's C-quoting on names holding a quote, a backslash or a control character, so those names never matched a real path.
  • gitfame/_gitfame.py blame_file: git blame ... <branch> -- <fname>, so a name starting with - is a path rather than an option.
  • tests/test_gitfame.py test_awkward_names_loc: a repository of two-line files named middle-safe.txt and -dash.txt, plus on POSIX leading.txt, trailing.txt , a"b.txt, a\b.txt and a tab-holding name, must total two lines per file and count every file.

Testing

  • pytest -q -p no:cacheprovider --no-cov tests (Python 3.13, Linux) on 258dbd8, this change rebased onto d793b35: 54 passed in 2.34s.
  • Each limb mutated back to its old form, the new test alone run against it, the fix restored after (cmp against the saved copy, git status --short showing only the two edited files):
    • -- dropped: assert (12, 6) == (14, 7), failed.
    • ls-files back to the newline split: assert (4, 2) == (14, 7), failed.
    • grep back to the newline split: assert (6, 3) == (14, 7), failed.
  • This branch's push CI on 258dbd8: the ci workflow's Ubuntu 3.8 (ubuntu-24.04) and 3.14, macOS 3.14 and Windows 3.14 cells all pass (this repository's test job skips pull requests opened by the owner, so the push run is the CI).

Follow-ups / Known Limitations

  • The --numstat path (--loc other than surv) still reads newline-separated git log output; it is unchanged here.

Footer

Generated by Claude Opus 5.5 (implementation, testing)

…ld parse as options

List tracked and text files NUL-separated, so a leading space on the first
name or a trailing space on the last survives, and names Git C-quotes (a
quote, a backslash, a control character) are blamed under their real name.
Pass `--` before the path to `git blame`, so a name starting with `-` is not
read as an option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 43218597853

Coverage at 92.888% (no base build to compare)

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 4 of 4 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 936
Covered Lines: 884
Line Coverage: 94.44%
Relevant Branches: 892
Covered Branches: 814
Branch Coverage: 91.26%
Branches in Coverage %: Yes
Coverage Strength: 3.77 hits per line

💛 - Coveralls

@Nitjsefnie
Nitjsefnie marked this pull request as ready for review November 12, 2026 14:48
@Nitjsefnie
Nitjsefnie merged commit c11d13a into perf-blame Nov 12, 2026
9 checks passed
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