mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-15 09:25:28 +02:00
fix(evidence): carry the real index mtime onto gstack-wtree's temp copy
The stat-cache seed (cp of the real index) stamped the temp index "now", which defeats git's racy-git protection: an entry is only re-hashed when its cached mtime is not older than the index file itself, so a same-size rewrite landing in the same second as the last real index write looked non-racy, kept its stale stat-cache entry, and vanished from the fingerprint — evidence stayed FRESH after a source change. This is the CI flake in test/evidence.test.ts "allow-paths carve-out" (sub-second alignment on fast runners: expected STALE exit 1, got FRESH exit 0). touch -r restores the original index timestamp, reinstating the exact racy window git itself uses. Deterministic regression pin in test/review-log.test.ts reproduces the miss with pinned zero-nsec timestamps (fails on the old script, passes now); receipts: manual probe shows the fresh-stamped copy returning the clean tree for a same-size 'hello'→'howdy' rewrite while the mtime-carried copy detects it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -42,7 +42,13 @@ case "$REAL_INDEX" in
|
||||
*) REAL_INDEX="$TOP/$REAL_INDEX" ;;
|
||||
esac
|
||||
if [ -n "$REAL_INDEX" ] && [ -f "$REAL_INDEX" ] && cp "$REAL_INDEX" "$TMPIDX" 2>/dev/null; then
|
||||
: # stat-cache-preserving seed
|
||||
# Carry the real index's mtime onto the copy. Git's racy-git protection
|
||||
# re-hashes any entry whose cached mtime is not older than the index file
|
||||
# itself; `cp` stamps the copy "now", which silently marks every entry
|
||||
# non-racy and lets a same-size rewrite in the same second as the original
|
||||
# `git add` keep its stale stat-cache entry — the content change vanishes
|
||||
# from the fingerprint. touch -r restores the original racy window.
|
||||
touch -r "$REAL_INDEX" "$TMPIDX" 2>/dev/null || true
|
||||
else
|
||||
git -C "$TOP" read-tree HEAD 2>/dev/null || exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user