]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5309-pack-delta-cycles.sh
remote-curl: error on incomplete packet
[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'
4. ./test-lib.sh
5. "$TEST_DIRECTORY"/lib-pack.sh
6
7# Two similar-ish objects that we have computed deltas between.
a79eec22 8A=$(test_oid packlib_7_0)
9B=$(test_oid packlib_7_76)
3b910d0c
JK
10
11# double-check our hand-constucted packs
12test_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
25test_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
38test_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
48test_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
a2178101 59test_expect_success 'failover to an object in another pack' '
b2ef3d9e
JK
60 clear_packs &&
61 git index-pack --stdin <ab.pack &&
a2178101 62 test_must_fail git index-pack --stdin --fix-thin <cycle.pack
b2ef3d9e
JK
63'
64
a2178101 65test_expect_success 'failover to a duplicate object in the same pack' '
b2ef3d9e
JK
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 &&
a2178101 74 test_must_fail git index-pack --fix-thin --stdin <recoverable.pack
b2ef3d9e
JK
75'
76
3b910d0c 77test_done