diff options
| author | Mohamed Hegazy <8000722+mhegazy@users.noreply.github.com> | 2026-05-29 08:11:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-29 08:11:25 -0700 |
| commit | 9e150cfd48b87280cc76e035de04a11aa604e9c5 (patch) | |
| tree | 10999652ee006e6b6d7c6c58f097399511abdf35 /plugins/security-guidance/hooks/gitutil.py | |
| parent | 8435428dfc0fd6e4fea1c8e505ef5022b1f0d403 (diff) | |
| parent | 38b298d5b29ece40893d3469ee1b3fe7b234494a (diff) | |
Merge pull request #2086 from anthropics/fix-2082-diff-parser-non-ascii
security-guidance: pass core.quotePath=false to diff feeders (#2082)
Diffstat (limited to 'plugins/security-guidance/hooks/gitutil.py')
| -rw-r--r-- | plugins/security-guidance/hooks/gitutil.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/plugins/security-guidance/hooks/gitutil.py b/plugins/security-guidance/hooks/gitutil.py index 68e6f13a..5495d18f 100644 --- a/plugins/security-guidance/hooks/gitutil.py +++ b/plugins/security-guidance/hooks/gitutil.py @@ -199,8 +199,15 @@ def _git_diff_range(repo_root, base, head="HEAD"): them reviewed — otherwise unreviewed commits get permanently silenced. """ try: + # core.quotePath=false makes git emit raw UTF-8 in `diff --git a/... b/...` + # headers instead of C-quoting non-ASCII path bytes (`"a/\303\201vila/..."` + # vs `a/Ávila/...`). The downstream `re.match(r'^a/(.+?) b/(.+)$', ...)` + # in parse_diff_into_files / extract_file_paths_from_diff matches the + # raw form only — quoted headers slip past and the entire file is + # silently dropped from review. See #2082 (sibling of #2056 / #2075). r = subprocess.run( - [*GIT_CMD, "diff", "-p", "--no-color", "--no-ext-diff", base, head], + [*GIT_CMD, "-c", "core.quotePath=false", + "diff", "-p", "--no-color", "--no-ext-diff", base, head], cwd=repo_root, capture_output=True, timeout=30, ) if r.returncode != 0: @@ -436,7 +443,11 @@ def get_git_diff(cwd, baseline_sha, full_context=False, paths=None, untracked_pa # change exists to fix. return "" - cmd = [*GIT_CMD, "diff", "--no-color", "--no-ext-diff", baseline_sha] + (["--unified=99999"] if full_context else []) + pathspec + # core.quotePath=false: emit raw UTF-8 in `diff --git a/... b/...` headers + # so non-ASCII paths aren't C-quoted past the downstream parse_diff_into_files + # regex. See #2082 (sibling of #2056 / #2075). + cmd = [*GIT_CMD, "-c", "core.quotePath=false", + "diff", "--no-color", "--no-ext-diff", baseline_sha] + (["--unified=99999"] if full_context else []) + pathspec try: with _temp_index(cwd, untracked_paths) as env: # env is None when no index could be found (bare repo / not a |
