diff options
| author | Mohamed Hegazy <mhegazy@anthropic.com> | 2026-10-27 20:08:34 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-10-27 21:23:30 +0000 |
| commit | f1b930f0368e0e0a096442eaa9c1c951b8076b71 (patch) | |
| tree | b9c2a907269897c4131ce4c64eefd5c9652e4865 /plugins/security-guidance/hooks/gitutil.py | |
| parent | f8c5e7a1dcb71b10cb74586224b5401f3de5db28 (diff) | |
security-guidance: take the turn baseline without git stash createmhegazy/sg-prompt-snapshot
stash create checks the work tree on one thread. add -u into the throwaway
index copy, write-tree and commit-tree produce the same commit and use git's
index preload instead, which matters where each file status is slow. See #6854.
Diffstat (limited to 'plugins/security-guidance/hooks/gitutil.py')
| -rw-r--r-- | plugins/security-guidance/hooks/gitutil.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/security-guidance/hooks/gitutil.py b/plugins/security-guidance/hooks/gitutil.py index ec51e3c6..de764d57 100644 --- a/plugins/security-guidance/hooks/gitutil.py +++ b/plugins/security-guidance/hooks/gitutil.py @@ -794,6 +794,11 @@ def _gitlink_paths(top, env): return found +# True when the last _drop_gitlinks call removed at least one gitlink, so the +# index copy and HEAD can no longer have the same tree even on a clean tree. +last_dropped_gitlinks = False + + def _drop_gitlinks(top, env, tmp_index): """Remove the gitlink (mode 160000) entry of every nested repository from the index copy that `env` names, never from the real index, before @@ -805,6 +810,8 @@ def _drop_gitlinks(top, env, tmp_index): `git stash create` fails on the empty directory. `top` is the work tree's top directory. Returns True on success, False on any failure; the copy must not be used then.""" + global last_dropped_gitlinks + last_dropped_gitlinks = False try: if not _may_have_gitlinks(tmp_index): return True @@ -829,6 +836,7 @@ def _drop_gitlinks(top, env, tmp_index): return False # Keep the mtime the copy came with; see _copied_index. os.utime(tmp_index, ns=(mtime_ns, mtime_ns)) + last_dropped_gitlinks = True debug_log(f"gitlink entries (nested repositories) removed from the " f"index copy: {len(nested)}; their contents are not reviewed") return True |
