mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-11 23:49:01 +02:00
fix(wtree): a failed touch falls through to the HEAD seed instead of reopening the racy window (#2687)
The v1.74 racy-git fix carries the real index's mtime onto the temp copy —
but its 'touch -r … || true' meant a FAILED touch silently kept the copy's
fresh stamp, marking every entry non-racy and reopening the exact same-size-
rewrite hole. A failed touch now discards the copy and seeds from read-tree
HEAD (slower; every entry re-hashed; fingerprint stays honest).
Verification for #2687 itself: the reporter's same-size-rewrite repro run 20
iterations against this tree — 0 misses (the underlying race was fixed by
v1.74's b1485d88 with its own regression test; this wave verifies and closes,
it does not claim that fix). Receipt: the stubbed-touch test fails on a
v1.77.0.0 scratch worktree.
Fixes #2687
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
78cd06e157
commit
d4b0131636
+7
-1
@@ -48,7 +48,13 @@ if [ -n "$REAL_INDEX" ] && [ -f "$REAL_INDEX" ] && cp "$REAL_INDEX" "$TMPIDX" 2>
|
||||
# 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
|
||||
# #2687 hardening: a FAILED touch silently reopened that exact hole (the
|
||||
# copy keeps its "now" stamp). Fall through to the HEAD seed instead —
|
||||
# slower, but every entry gets re-hashed, so the fingerprint stays honest.
|
||||
if ! touch -r "$REAL_INDEX" "$TMPIDX" 2>/dev/null; then
|
||||
rm -f "$TMPIDX" 2>/dev/null || true
|
||||
git -C "$TOP" read-tree HEAD 2>/dev/null || exit 1
|
||||
fi
|
||||
else
|
||||
git -C "$TOP" read-tree HEAD 2>/dev/null || exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user