]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5309-pack-delta-cycles.sh
The third batch
[thirdparty/git.git] / t / t5309-pack-delta-cycles.sh
CommitLineData
3b910d0c
JK
1#!/bin/sh
2
3test_description='test index-pack handling of delta cycles in packfiles'
330ca850
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
3b910d0c
JK
6. ./test-lib.sh
7. "$TEST_DIRECTORY"/lib-pack.sh
8
9# Two similar-ish objects that we have computed deltas between.
a79eec22 10A=$(test_oid packlib_7_0)
11B=$(test_oid packlib_7_76)
3b910d0c
JK
12
13# double-check our hand-constucted packs
14test_expect_success 'index-pack works with a single delta (A->B)' '
15 clear_packs &&
16 {
17 pack_header 2 &&
18 pack_obj $A $B &&
19 pack_obj $B
20 } >ab.pack &&
21 pack_trailer ab.pack &&
22 git index-pack --stdin <ab.pack &&
23 git cat-file -t $A &&
24 git cat-file -t $B
25'
26
27test_expect_success 'index-pack works with a single delta (B->A)' '
28 clear_packs &&
29 {
30 pack_header 2 &&
31 pack_obj $A &&
32 pack_obj $B $A
33 } >ba.pack &&
34 pack_trailer ba.pack &&
35 git index-pack --stdin <ba.pack &&
36 git cat-file -t $A &&
37 git cat-file -t $B
38'
39
40test_expect_success 'index-pack detects missing base objects' '
41 clear_packs &&
42 {
43 pack_header 1 &&
44 pack_obj $A $B
45 } >missing.pack &&
46 pack_trailer missing.pack &&
47 test_must_fail git index-pack --fix-thin --stdin <missing.pack
48'
49
50test_expect_success 'index-pack detects REF_DELTA cycles' '
51 clear_packs &&
52 {
53 pack_header 2 &&
54 pack_obj $A $B &&
55 pack_obj $B $A
56 } >cycle.pack &&
57 pack_trailer cycle.pack &&
58 test_must_fail git index-pack --fix-thin --stdin <cycle.pack
59'
60
a2178101 61test_expect_success 'failover to an object in another pack' '
b2ef3d9e
JK
62 clear_packs &&
63 git index-pack --stdin <ab.pack &&
a2178101 64 test_must_fail git index-pack --stdin --fix-thin <cycle.pack
b2ef3d9e
JK
65'
66
a2178101 67test_expect_success 'failover to a duplicate object in the same pack' '
b2ef3d9e
JK
68 clear_packs &&
69 {
70 pack_header 3 &&
71 pack_obj $A $B &&
72 pack_obj $B $A &&
73 pack_obj $A
74 } >recoverable.pack &&
75 pack_trailer recoverable.pack &&
a2178101 76 test_must_fail git index-pack --fix-thin --stdin <recoverable.pack
b2ef3d9e
JK
77'
78
3b910d0c 79test_done