summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks/gitutil.py
diff options
context:
space:
mode:
authorMohamed Hegazy <mhegazy@anthropic.com>2026-10-13 20:57:12 +0000
committerClaude <noreply@anthropic.com>2026-10-13 20:57:12 +0000
commiteb638fbf680ae279a9e6699d2243344ccddc9624 (patch)
tree1395791e035b6378d770bd10a7fddda517dba16b /plugins/security-guidance/hooks/gitutil.py
parentf359d43b406057f1a8cdbc4ea93b827642c162e6 (diff)
security-guidance: read diffs the same whatever the user's prefix settings
With diff.mnemonicPrefix or diff.noprefix set in the user's git config, diff headers no longer read `a/<path> b/<path>`, the parser matched no file, and the review was skipped with nothing shown. mnemonicPrefix switched off the Stop review; noprefix switched off the commit and push reviews as well. Pass the default prefix settings on every git call the hook makes. Fixes #4569
Diffstat (limited to 'plugins/security-guidance/hooks/gitutil.py')
-rw-r--r--plugins/security-guidance/hooks/gitutil.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/security-guidance/hooks/gitutil.py b/plugins/security-guidance/hooks/gitutil.py
index 2036b45e..03eac98b 100644
--- a/plugins/security-guidance/hooks/gitutil.py
+++ b/plugins/security-guidance/hooks/gitutil.py
@@ -41,6 +41,13 @@ GIT_CMD = [
# content same) rewrites the index under index.lock, GIT_OPTIONAL_LOCKS or
# not. Off, every diff here only reads the index, so none needs a copy.
"-c", "diff.autoRefreshIndex=false",
+ # The diff parsers read `diff --git a/<old> b/<new>` headers. A user's
+ # diff.mnemonicPrefix (c/ w/ i/), diff.noprefix or diff.srcPrefix /
+ # diff.dstPrefix changes that shape, and every file would be dropped.
+ "-c", "diff.mnemonicPrefix=false",
+ "-c", "diff.noprefix=false",
+ "-c", "diff.srcPrefix=a/",
+ "-c", "diff.dstPrefix=b/",
]
SAFE_GIT_CONFIG = (