fix(git): show non-ASCII paths unescaped in git_status and git_diff* - #4879
Open
tsurutanmen wants to merge 1 commit into
Open
tsurutanmen wants to merge 1 commit into
tsurutanmen wants to merge 1 commit into
Conversation
git's default core.quotepath=true makes `git status` and `git diff` print non-ASCII paths as quoted octal escapes, e.g. "\346\227\245\346\234\254\350\252\236.txt" for 日本語.txt. Clients cannot map these back to the real file, so pass `-c core.quotepath=false` for git_status, git_diff_unstaged, git_diff_staged and git_diff. git_show already reports decoded paths through GitPython's Diff objects and is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 tasks
This branch has not been deployed
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
git_status,git_diff_unstaged,git_diff_stagedandgit_diffreturn non-ASCII file names as quoted octal escapes, because git's defaultcore.quotepath=trueapplies to their output. A file named日本語.txtshows up as:and in diffs as
diff --git "a/\346\227\245\346\234\254\350\252\236.txt" .... An LLM client cannot map that back to the real file, so any follow-up call such asgit_addwith the escaped name fails. This PR runs these four commands with-c core.quotepath=false, so the same file shows up as日本語.txt.git_showis unchanged. It builds its output from GitPython'sDiffobjects, which already decode the paths.Server Details
git_status,git_diff_unstaged,git_diff_staged,git_diff)Motivation and Context
This affects any repository with non-ASCII file names: Japanese, Chinese, Korean, accented Latin, emoji, and so on. The setting only changes how git prints paths. It does not touch repository config, and it does not change output for ASCII paths.
How Has This Been Tested?
core.quotepath=truein the test repository, so the result does not depend on the user's global config. All 4 fail without the fix and pass with it.pyrightandruff checkare clean.claude -p(Claude Code) against a repository containing an untracked日本語.txtand had the model callgit_status. Before the fix, the output contained"\346\227\245\346\234\254\350\252\236.txt". After the fix, it contained日本語.txt.Tested on Windows 11 with git for Windows and Python 3.11. On Windows, the existing
test_repositoryfixture teardown raisesPermissionErrorfromshutil.rmtreewhile GitPython still holds handles. This happens before and after this change and is unrelated to it. CI on Linux is not affected.Breaking Changes
None. ASCII output is identical. Clients that were parsing the escaped form will now receive the real UTF-8 path.
Types of changes
Checklist
Additional context
-c core.quotepath=falseis passed per command through GitPython (repo.git(c=...)), so it applies only to that single invocation.🤖 Generated with Claude Code