Merge branch 'js/pu-to-seen' into master
[git/debian.git] / t / t5309-pack-delta-cycles.sh
blob55b787630fcb6e0631bc6b8a1cd6626c30063417
1 #!/bin/sh
3 test_description='test index-pack handling of delta cycles in packfiles'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-pack.sh
7 # Two similar-ish objects that we have computed deltas between.
8 A=$(test_oid packlib_7_0)
9 B=$(test_oid packlib_7_76)
11 # double-check our hand-constucted packs
12 test_expect_success 'index-pack works with a single delta (A->B)' '
13 clear_packs &&
15 pack_header 2 &&
16 pack_obj $A $B &&
17 pack_obj $B
18 } >ab.pack &&
19 pack_trailer ab.pack &&
20 git index-pack --stdin <ab.pack &&
21 git cat-file -t $A &&
22 git cat-file -t $B
25 test_expect_success 'index-pack works with a single delta (B->A)' '
26 clear_packs &&
28 pack_header 2 &&
29 pack_obj $A &&
30 pack_obj $B $A
31 } >ba.pack &&
32 pack_trailer ba.pack &&
33 git index-pack --stdin <ba.pack &&
34 git cat-file -t $A &&
35 git cat-file -t $B
38 test_expect_success 'index-pack detects missing base objects' '
39 clear_packs &&
41 pack_header 1 &&
42 pack_obj $A $B
43 } >missing.pack &&
44 pack_trailer missing.pack &&
45 test_must_fail git index-pack --fix-thin --stdin <missing.pack
48 test_expect_success 'index-pack detects REF_DELTA cycles' '
49 clear_packs &&
51 pack_header 2 &&
52 pack_obj $A $B &&
53 pack_obj $B $A
54 } >cycle.pack &&
55 pack_trailer cycle.pack &&
56 test_must_fail git index-pack --fix-thin --stdin <cycle.pack
59 test_expect_success 'failover to an object in another pack' '
60 clear_packs &&
61 git index-pack --stdin <ab.pack &&
62 test_must_fail git index-pack --stdin --fix-thin <cycle.pack
65 test_expect_success 'failover to a duplicate object in the same pack' '
66 clear_packs &&
68 pack_header 3 &&
69 pack_obj $A $B &&
70 pack_obj $B $A &&
71 pack_obj $A
72 } >recoverable.pack &&
73 pack_trailer recoverable.pack &&
74 test_must_fail git index-pack --fix-thin --stdin <recoverable.pack
77 test_done