Skip to content

fix(stats): preserve Unicode line separators in filenames - #2301

Open
BHARTIYAYASH wants to merge 1 commit into
gitpython-developers:mainfrom
BHARTIYAYASH:fix/commit-stats-unicode-lines
Open

BHARTIYAYASH wants to merge 1 commit into
gitpython-developers:mainfrom
BHARTIYAYASH:fix/commit-stats-unicode-lines

Conversation

@BHARTIYAYASH

Copy link
Copy Markdown

Problem

With core.quotePath=false, Git emits U+0085, U+2028 and U+2029 directly in filenames. Commit.stats and Stats._list_from_string use str.splitlines(), which treats those filename characters as record boundaries. Statistics for these valid paths raise ValueError.

Change

Split Git's records only at line feeds, preserving filename characters. Skip empty records so empty commits and the generated text's trailing newline continue to work. No public types or filename encodings change.

The regression uses actual Git output and covers all three Unicode separators, root commits, subsequent modifications and an empty commit. Blobs are stored directly in the index, following the existing filename-whitespace regression.

Verification

  • The new regression failed before the implementation change.
  • Complete commit/statistics modules: 44 passed, 8 subtests passed.
  • Ruff lint and formatting, mypy on both changed source modules, and git diff --check passed.

Prepared and submitted by OpenAI Codex, an AI agent operating through BHARTIYAYASH's account. Human review is pending.

With `core.quotePath=false`, Git emits U+0085, U+2028 and U+2029 directly
in filenames. `Commit.stats` and `Stats._list_from_string` used
`str.splitlines()`, treating those filename characters as record endings
and raising `ValueError` instead of returning statistics.

Split only at the line feeds used by Git's protocol. Keep empty commits
and the generated text's trailing newline working by ignoring empty
records. No filename encoding or public return types change.

The regression uses real Git output for all three Unicode separators
and covers root, later and empty commits. It failed before this change.
The complete commit/statistics modules passed: 44 tests and 8 subtests.
Ruff lint/format, mypy for both changed source files, and `git diff
--check` also passed.
@BHARTIYAYASH
BHARTIYAYASH marked this pull request as ready for review October 22, 2026 16:03
@Byron
Byron requested a balanced review from Copilot October 22, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused parsing changes address the reported failure, include relevant regression coverage, and have no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR fixes statistics parsing for valid filenames containing Unicode line separators without changing public types or filename encodings.

Changes:

  • Split Git output only on line feeds, preserving Unicode separators within filenames.
  • Skip empty records to handle empty commits and trailing newlines.
  • Add regression coverage for all three separators across root commits, modifications, and an empty commit.
File Description
test/​test_commit.py Adds regression coverage using actual Git output.
git/​util.py Preserves Unicode separators when parsing statistics records.
git/​objects/​commit.py Uses line-feed-only splitting for both commit statistics paths.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants