1#!/bin/sh
23
test_description='test index-pack handling of delta cycles in packfiles'
4. ./test-lib.sh
5. "$TEST_DIRECTORY"/lib-pack.sh
67
# Two similar-ish objects that we have computed deltas between.
8A=01d7713666f4de822776c7622c10f1b07de280dc
9B=e68fe8129b546b101aee9510c5328e7f21ca1d18
1011
# double-check our hand-constucted packs
12test_expect_success 'index-pack works with a single delta (A->B)' '
13clear_packs &&
14{
15pack_header 2 &&
16pack_obj $A $B &&
17pack_obj $B
18} >ab.pack &&
19pack_trailer ab.pack &&
20git index-pack --stdin <ab.pack &&
21git cat-file -t $A &&
22git cat-file -t $B
23'
2425
test_expect_success 'index-pack works with a single delta (B->A)' '
26clear_packs &&
27{
28pack_header 2 &&
29pack_obj $A &&
30pack_obj $B $A
31} >ba.pack &&
32pack_trailer ba.pack &&
33git index-pack --stdin <ba.pack &&
34git cat-file -t $A &&
35git cat-file -t $B
36'
3738
test_expect_success 'index-pack detects missing base objects' '
39clear_packs &&
40{
41pack_header 1 &&
42pack_obj $A $B
43} >missing.pack &&
44pack_trailer missing.pack &&
45test_must_fail git index-pack --fix-thin --stdin <missing.pack
46'
4748
test_expect_success 'index-pack detects REF_DELTA cycles' '
49clear_packs &&
50{
51pack_header 2 &&
52pack_obj $A $B &&
53pack_obj $B $A
54} >cycle.pack &&
55pack_trailer cycle.pack &&
56test_must_fail git index-pack --fix-thin --stdin <cycle.pack
57'
5859
test_expect_failure 'failover to an object in another pack' '
60clear_packs &&
61git index-pack --stdin <ab.pack &&
62git index-pack --stdin --fix-thin <cycle.pack
63'
6465
test_expect_failure 'failover to a duplicate object in the same pack' '
66clear_packs &&
67{
68pack_header 3 &&
69pack_obj $A $B &&
70pack_obj $B $A &&
71pack_obj $A
72} >recoverable.pack &&
73pack_trailer recoverable.pack &&
74git index-pack --fix-thin --stdin <recoverable.pack
75'
7677
test_done