Merge branch 'jk/stash-list-p' into jch
[git/jrn.git] / t / t5309-pack-delta-cycles.sh
blob3e7861b075ffa54f0214aaa349df33be7a113d35
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=01d7713666f4de822776c7622c10f1b07de280dc
9 B=e68fe8129b546b101aee9510c5328e7f21ca1d18
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_failure 'failover to an object in another pack' '
60 clear_packs &&
61 git index-pack --stdin <ab.pack &&
62 git index-pack --stdin --fix-thin <cycle.pack
65 test_expect_failure '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 git index-pack --fix-thin --stdin <recoverable.pack
77 test_done