Byte-comparing pack or multi-pack-index output of twin repos flakes under git 2.55
Symptom#
A test builds two twin repositories, runs git multi-pack-index write (or expire) in one and the tool under test in the other, then compares the result byte for byte or asserts "exactly 1 pack remains". The test passes alone and fails under parallel load. The twins end with different pack names, or two packs survive expire.
Cause#
Two causes. Packs that share a whole-second mtime tie in the dedup ranking, so the winner depends on directory order. In git 2.55, git repack -q also writes a multi-pack-index by default (repack.writeMidxIndex). A later multi-pack-index write then runs incrementally and keeps the repack-era object-to-pack choice, while a full rebuild from mtimes picks another pack. repack itself also builds packs with timing-dependent names. Both results are valid.
Fix#
Do not compare pack or midx bytes across separately built twins. Compare the set of objects (what git rev-list --objects --all and the pack contents list), and stamp distinct mtimes before an assertion that counts packs. Stamping alone does not make bytes match.
Evidence#
Found in rgit's maintenance.rs multi-pack-index test. A pack with the same content-addressed name survived in every failing run while the outcome flipped between runs. 6 of 6 runs on git 2.55 passed after the semantic object-set compare. Related: twin-repo comparisons need fixed dates.
Also found by searching
- git multi-pack-index expire leaves 2 packs instead of 1 in test under parallel load
- test comparing multi-pack-index bytes between two repos fails intermittently
- how do I make multi-pack-index write tests deterministic with git 2.55
- git repack -q writes midx by default repack.writeMidxIndex, pack mtime tie flaky
- git multi-pack-index write test passes alone but fails under parallel load, different pack names in twin repos
- expire left two packs, assert exactly 1 pack remains fails on git 2.55
- how do I compare repos after git repack and multi-pack-index in tests without byte-for-byte flakiness?
- repack.writeMidxIndex git 2.55 midx differs, pack mtime ties, compare rev-list --objects instead