]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5309-pack-delta-cycles.sh
upload-pack: move allow_unadvertised_object_request to upload_pack_data
[thirdparty/git.git] / t / t5309-pack-delta-cycles.sh
1 #!/bin/sh
2
3 test_description='test index-pack handling of delta cycles in packfiles'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY"/lib-pack.sh
6
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)
10
11 # double-check our hand-constucted packs
12 test_expect_success 'index-pack works with a single delta (A->B)' '
13 clear_packs &&
14 {
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
23 '
24
25 test_expect_success 'index-pack works with a single delta (B->A)' '
26 clear_packs &&
27 {
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
36 '
37
38 test_expect_success 'index-pack detects missing base objects' '
39 clear_packs &&
40 {
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
46 '
47
48 test_expect_success 'index-pack detects REF_DELTA cycles' '
49 clear_packs &&
50 {
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
57 '
58
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
63 '
64
65 test_expect_success 'failover to a duplicate object in the same pack' '
66 clear_packs &&
67 {
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
75 '
76
77 test_done