Fix create_patch with mnemonic diff prefixes#2178
Closed
KSHITIZ6341 wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
diff.mnemonicPrefixfor Git commands whose output GitPython parsesDiffable.diffpath and the index-versus-empty-tree implementationFixes #2013.
Root cause
With
diff.mnemonicPrefix=truein Git configuration, Git emits prefixes such asc/,i/, andw/. GitPython's patch parser expects the standarda/andb/prefixes, socreate_patch=Truesilently returned an emptyDiffIndex.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.pypython -m compileall -q git test/test_diff.pygit diff --checkAI disclosure
This pull request was prepared and submitted by OpenAI Codex acting as an AI agent through the contributor's GitHub account.