1#!/bin/sh23test_description='test index-pack handling of delta cycles in packfiles'4. ./test-lib.sh5. "$TEST_DIRECTORY"/lib-pack.sh67# Two similar-ish objects that we have computed deltas between.8A=01d7713666f4de822776c7622c10f1b07de280dc9B=e68fe8129b546b101aee9510c5328e7f21ca1d181011# double-check our hand-constucted packs12test_expect_success 'index-pack works with a single delta (A->B)' '13clear_packs &&14{15pack_header 2 &&16pack_obj $A $B &&17pack_obj $B18} >ab.pack &&19pack_trailer ab.pack &&20git index-pack --stdin <ab.pack &&21git cat-file -t $A &&22git cat-file -t $B23'2425test_expect_success 'index-pack works with a single delta (B->A)' '26clear_packs &&27{28pack_header 2 &&29pack_obj $A &&30pack_obj $B $A31} >ba.pack &&32pack_trailer ba.pack &&33git index-pack --stdin <ba.pack &&34git cat-file -t $A &&35git cat-file -t $B36'3738test_expect_success 'index-pack detects missing base objects' '39clear_packs &&40{41pack_header 1 &&42pack_obj $A $B43} >missing.pack &&44pack_trailer missing.pack &&45test_must_fail git index-pack --fix-thin --stdin <missing.pack46'4748test_expect_success 'index-pack detects REF_DELTA cycles' '49clear_packs &&50{51pack_header 2 &&52pack_obj $A $B &&53pack_obj $B $A54} >cycle.pack &&55pack_trailer cycle.pack &&56test_must_fail git index-pack --fix-thin --stdin <cycle.pack57'5859test_expect_failure 'failover to an object in another pack' '60clear_packs &&61git index-pack --stdin <ab.pack &&62git index-pack --stdin --fix-thin <cycle.pack63'6465test_expect_failure 'failover to a duplicate object in the same pack' '66clear_packs &&67{68pack_header 3 &&69pack_obj $A $B &&70pack_obj $B $A &&71pack_obj $A72} >recoverable.pack &&73pack_trailer recoverable.pack &&74git index-pack --fix-thin --stdin <recoverable.pack75'7677test_done