#!/bin/sh global test_description := ''test index-pack handling of delta cycles in packfiles'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-pack.sh # Two similar-ish objects that we have computed deltas between. global A := '01d7713666f4de822776c7622c10f1b07de280dc' global B := 'e68fe8129b546b101aee9510c5328e7f21ca1d18' # double-check our hand-constucted packs test_expect_success 'index-pack works with a single delta (A->B)' ' clear_packs && { pack_header 2 && pack_obj $A $B && pack_obj $B } >ab.pack && pack_trailer ab.pack && git index-pack --stdin A)' ' clear_packs && { pack_header 2 && pack_obj $A && pack_obj $B $A } >ba.pack && pack_trailer ba.pack && git index-pack --stdin missing.pack && pack_trailer missing.pack && test_must_fail git index-pack --fix-thin --stdin cycle.pack && pack_trailer cycle.pack && test_must_fail git index-pack --fix-thin --stdin recoverable.pack && pack_trailer recoverable.pack && git index-pack --fix-thin --stdin )} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-pack.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:A) op: Equal rhs: {(01d7713666f4de822776c7622c10f1b07de280dc)} spids: [24] ) ] spids: [24] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:B) op: Equal rhs: {(e68fe8129b546b101aee9510c5328e7f21ca1d18)} spids: [27] ) ] spids: [27] ) (C {(test_expect_success)} {(SQ <"index-pack works with a single delta (A->B)">)} { (SQ <"\n"> <"\tclear_packs &&\n"> <"\t{\n"> <"\t\tpack_header 2 &&\n"> <"\t\tpack_obj $A $B &&\n"> <"\t\tpack_obj $B\n"> <"\t} >ab.pack &&\n"> <"\tpack_trailer ab.pack &&\n"> <"\tgit index-pack --stdin <"\tgit cat-file -t $A &&\n"> <"\tgit cat-file -t $B\n"> ) } ) (C {(test_expect_success)} {(SQ <"index-pack works with a single delta (B->A)">)} { (SQ <"\n"> <"\tclear_packs &&\n"> <"\t{\n"> <"\t\tpack_header 2 &&\n"> <"\t\tpack_obj $A &&\n"> <"\t\tpack_obj $B $A\n"> <"\t} >ba.pack &&\n"> <"\tpack_trailer ba.pack &&\n"> <"\tgit index-pack --stdin <"\tgit cat-file -t $A &&\n"> <"\tgit cat-file -t $B\n"> ) } ) (C {(test_expect_success)} {(SQ <"index-pack detects missing base objects">)} { (SQ <"\n"> <"\tclear_packs &&\n"> <"\t{\n"> <"\t\tpack_header 1 &&\n"> <"\t\tpack_obj $A $B\n"> <"\t} >missing.pack &&\n"> <"\tpack_trailer missing.pack &&\n"> <"\ttest_must_fail git index-pack --fix-thin --stdin ) } ) (C {(test_expect_success)} {(SQ <"index-pack detects REF_DELTA cycles">)} { (SQ <"\n"> <"\tclear_packs &&\n"> <"\t{\n"> <"\t\tpack_header 2 &&\n"> <"\t\tpack_obj $A $B &&\n"> <"\t\tpack_obj $B $A\n"> <"\t} >cycle.pack &&\n"> <"\tpack_trailer cycle.pack &&\n"> <"\ttest_must_fail git index-pack --fix-thin --stdin ) } ) (C {(test_expect_failure)} {(SQ <"failover to an object in another pack">)} { (SQ <"\n"> <"\tclear_packs &&\n"> <"\tgit index-pack --stdin <"\tgit index-pack --stdin --fix-thin ) } ) (C {(test_expect_failure)} {(SQ <"failover to a duplicate object in the same pack">)} { (SQ <"\n"> <"\tclear_packs &&\n"> <"\t{\n"> <"\t\tpack_header 3 &&\n"> <"\t\tpack_obj $A $B &&\n"> <"\t\tpack_obj $B $A &&\n"> <"\t\tpack_obj $A\n"> <"\t} >recoverable.pack &&\n"> <"\tpack_trailer recoverable.pack &&\n"> <"\tgit index-pack --fix-thin --stdin ) } ) (C {(test_done)}) ] )