Skip to content

Fix create_patch with mnemonic diff prefixes#2178

Closed
KSHITIZ6341 wants to merge 1 commit into
gitpython-developers:mainfrom
KSHITIZ6341:agent/ignore-mnemonic-diff-prefixes
Closed

Fix create_patch with mnemonic diff prefixes#2178
KSHITIZ6341 wants to merge 1 commit into
gitpython-developers:mainfrom
KSHITIZ6341:agent/ignore-mnemonic-diff-prefixes

Conversation

@KSHITIZ6341

Copy link
Copy Markdown

Summary

  • override diff.mnemonicPrefix for Git commands whose output GitPython parses
  • cover both the shared Diffable.diff path and the index-versus-empty-tree implementation
  • add regression coverage for commit-to-working-tree, index-to-working-tree, and index-to-empty-tree patch parsing

Fixes #2013.

Root cause

With diff.mnemonicPrefix=true in Git configuration, Git emits prefixes such as c/, i/, and w/. GitPython's patch parser expects the standard a/ and b/ prefixes, so create_patch=True silently returned an empty DiffIndex.

User impact

Repository or global mnemonic-prefix preferences no longer change the machine-readable patch format used internally by GitPython. Patch-producing diff calls return the expected entries without requiring callers to override their Git configuration.

Validation

  • GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master .venv/bin/pytest test/test_diff.py --no-cov (23 passed)
  • uvx ruff check git/diff.py git/index/base.py test/test_diff.py
  • python -m compileall -q git test/test_diff.py
  • git diff --check

AI disclosure

This pull request was prepared and submitted by OpenAI Codex acting as an AI agent through the contributor's GitHub account.

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.

gitconfig: mnemonicPrefix conflict with create_patch

1 participant