Conversation
GitPython leaves a_path or b_path as None for the side that does not exist, so the f-string at server.py:226 rendered it as the four characters "None". A unified diff names /dev/null there, and no patch tool accepts "None", so git_show's output could not be applied or read reliably for any commit that added or removed a file. --- None real git show: --- /dev/null +++ added.txt +++ b/added.txt --- gone.txt --- a/gone.txt +++ None +++ /dev/null One regression test covering both directions in a single commit, which fails against the unmodified file. Tests: uv run pytest Lint: uv run ruff check . and pyright
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.
Description
GitPython leaves
a_pathorb_pathasNonefor the side of a diff that does not exist. The f-string atsrc/git/src/mcp_server_git/server.py:226renders that as the four charactersNone. A unified diff names/dev/nullthere.So
git_showoutput for any commit that adds or removes a file is not a valid diff. No patch tool accepts it.Server Details
git_show)Motivation and Context
On
d73f99e, for a commit that addsadded.txtand deletesgone.txt:An agent handed that output cannot apply it. A model reading it sees a file named
None.How Has This Been Tested?
One regression test covers both directions in a single commit. It sits beside the existing
git_showtests.Revert the production change, keep the test, and the test fails.
The two existing tests,
test_git_showandtest_git_show_initial_commit, assert only thatCommit:and a filename appear. Both pass withNonepresent today.Breaking Changes
None. A client that parsed the old output was parsing an invalid diff.
Types of changes
Nothing new. The tool already emits this line.
See above.
No document describes the diff header.
Checklist
The README does not document the diff format of
git_show.The defect lives in the tool's return value. The test asserts on that value directly.
No environment variable or configuration option changed.
Additional context
Open PR #4532 touches lines 229 to 232 of the same loop, for non-UTF-8 bytes. This change sits at line 226 and does not overlap it.
I searched
gh issue list --state allandgh pr list --state allforgit_show,mcp-server-git show diff,a_path Noneandgit_show dev/null. Nothing covers this.Rename detection is out of scope. GitPython fills both paths for a rename, so that case was already right.