]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5500-fetch-pack.sh
drop "match" parameter from get_remote_heads
[thirdparty/git.git] / t / t5500-fetch-pack.sh
CommitLineData
6b17c674
JS
1#!/bin/sh
2#
3# Copyright (c) 2005 Johannes Schindelin
4#
5
3902985a 6test_description='Testing multi_ack pack fetching'
6b17c674 7
6b17c674
JS
8. ./test-lib.sh
9
10# Test fetch-pack/upload-pack pair.
11
12# Some convenience functions
13
1010437d 14add () {
3902985a
SB
15 name=$1 &&
16 text="$@" &&
17 branch=`echo $name | sed -e 's/^\(.\).*$/\1/'` &&
18 parents="" &&
6b17c674 19
3902985a 20 shift &&
6b17c674 21 while test $1; do
3902985a 22 parents="$parents -p $1" &&
6b17c674 23 shift
3902985a 24 done &&
6b17c674 25
3902985a
SB
26 echo "$text" > test.txt &&
27 git update-index --add test.txt &&
28 tree=$(git write-tree) &&
6b17c674 29 # make sure timestamps are in correct order
3902985a
SB
30 test_tick &&
31 commit=$(echo "$text" | git commit-tree $tree $parents) &&
32 eval "$name=$commit; export $name" &&
33 echo $commit > .git/refs/heads/$branch &&
6b17c674
JS
34 eval ${branch}TIP=$commit
35}
36
1010437d 37pull_to_client () {
3902985a
SB
38 number=$1 &&
39 heads=$2 &&
40 count=$3 &&
41 test_expect_success "$number pull" '
42 (
43 cd client &&
44 git fetch-pack -k -v .. $heads &&
45
46 case "$heads" in
47 *A*)
48 echo $ATIP > .git/refs/heads/A;;
49 esac &&
50 case "$heads" in *B*)
51 echo $BTIP > .git/refs/heads/B;;
52 esac &&
53 git symbolic-ref HEAD refs/heads/`echo $heads \
54 | sed -e "s/^\(.\).*$/\1/"` &&
55
56 git fsck --full &&
57
58 mv .git/objects/pack/pack-* . &&
59 p=`ls -1 pack-*.pack` &&
60 git unpack-objects <$p &&
61 git fsck --full &&
62
63 idx=`echo pack-*.idx` &&
64 pack_count=`git show-index <$idx | wc -l` &&
65 test $pack_count = $count &&
66 rm -f pack-*
67 )
68 '
6b17c674
JS
69}
70
71# Here begins the actual testing
72
73# A1 - ... - A20 - A21
74# \
75# B1 - B2 - .. - B70
76
77# client pulls A20, B1. Then tracks only B. Then pulls A.
78
3902985a 79test_expect_success 'setup' '
6b17c674 80 mkdir client &&
3902985a
SB
81 (
82 cd client &&
83 git init &&
84 git config transfer.unpacklimit 0
85 ) &&
86 add A1 &&
87 prev=1 &&
88 cur=2 &&
89 while [ $cur -le 10 ]; do
90 add A$cur $(eval echo \$A$prev) &&
91 prev=$cur &&
92 cur=$(($cur+1))
93 done &&
a48fcd83 94 add B1 $A1 &&
3902985a
SB
95 echo $ATIP > .git/refs/heads/A &&
96 echo $BTIP > .git/refs/heads/B &&
97 git symbolic-ref HEAD refs/heads/B
98'
6b17c674
JS
99
100pull_to_client 1st "B A" $((11*3))
101
3902985a
SB
102test_expect_success 'post 1st pull setup' '
103 add A11 $A10 &&
104 prev=1 &&
105 cur=2 &&
106 while [ $cur -le 65 ]; do
107 add B$cur $(eval echo \$B$prev) &&
108 prev=$cur &&
109 cur=$(($cur+1))
110 done
111'
6b17c674
JS
112
113pull_to_client 2nd "B" $((64*3))
114
3902985a 115pull_to_client 3rd "A" $((1*3))
16ad3579 116
3902985a
SB
117test_expect_success 'clone shallow' '
118 git clone --depth 2 "file://$(pwd)/." shallow
119'
37818d7d 120
3902985a
SB
121test_expect_success 'clone shallow object count' '
122 (
123 cd shallow &&
124 git count-objects -v
125 ) > count.shallow &&
126 grep "^in-pack: 18" count.shallow
37818d7d 127'
16ad3579 128
3902985a
SB
129test_expect_success 'clone shallow object count (part 2)' '
130 sed -e "/^in-pack:/d" -e "/^packs:/d" -e "/^size-pack:/d" \
131 -e "/: 0$/d" count.shallow > count_output &&
132 ! test -s count_output
133'
16ad3579 134
3902985a
SB
135test_expect_success 'fsck in shallow repo' '
136 (
137 cd shallow &&
138 git fsck --full
139 )
140'
16ad3579 141
86386829
NP
142test_expect_success 'simple fetch in shallow repo' '
143 (
144 cd shallow &&
145 git fetch
146 )
147'
148
149test_expect_success 'no changes expected' '
150 (
151 cd shallow &&
152 git count-objects -v
153 ) > count.shallow.2 &&
154 cmp count.shallow count.shallow.2
155'
156
157test_expect_success 'fetch same depth in shallow repo' '
158 (
159 cd shallow &&
160 git fetch --depth=2
161 )
162'
163
164test_expect_success 'no changes expected' '
165 (
166 cd shallow &&
167 git count-objects -v
168 ) > count.shallow.3 &&
169 cmp count.shallow count.shallow.3
170'
16ad3579 171
3902985a
SB
172test_expect_success 'add two more' '
173 add B66 $B65 &&
174 add B67 $B66
175'
16ad3579 176
3902985a
SB
177test_expect_success 'pull in shallow repo' '
178 (
179 cd shallow &&
180 git pull .. B
181 )
182'
16ad3579 183
3902985a
SB
184test_expect_success 'clone shallow object count' '
185 (
186 cd shallow &&
187 git count-objects -v
188 ) > count.shallow &&
189 grep "^count: 6" count.shallow
190'
16ad3579 191
3902985a
SB
192test_expect_success 'add two more (part 2)' '
193 add B68 $B67 &&
194 add B69 $B68
195'
16ad3579 196
3902985a
SB
197test_expect_success 'deepening pull in shallow repo' '
198 (
199 cd shallow &&
200 git pull --depth 4 .. B
201 )
202'
16ad3579 203
3902985a
SB
204test_expect_success 'clone shallow object count' '
205 (
206 cd shallow &&
207 git count-objects -v
208 ) > count.shallow &&
209 grep "^count: 12" count.shallow
210'
16ad3579 211
3902985a
SB
212test_expect_success 'deepening fetch in shallow repo' '
213 (
214 cd shallow &&
215 git fetch --depth 4 .. A:A
216 )
217'
16ad3579 218
3902985a
SB
219test_expect_success 'clone shallow object count' '
220 (
221 cd shallow &&
222 git count-objects -v
223 ) > count.shallow &&
224 grep "^count: 18" count.shallow
225'
16ad3579 226
3902985a
SB
227test_expect_success 'pull in shallow repo with missing merge base' '
228 (
229 cd shallow &&
230 test_must_fail git pull --depth 4 .. A
231 )
232'
16ad3579 233
86386829
NP
234test_expect_success 'additional simple shallow deepenings' '
235 (
236 cd shallow &&
237 git fetch --depth=8 &&
238 git fetch --depth=10 &&
239 git fetch --depth=11
240 )
241'
242
243test_expect_success 'clone shallow object count' '
244 (
245 cd shallow &&
246 git count-objects -v
247 ) > count.shallow &&
248 grep "^count: 52" count.shallow
249'
250
6b17c674 251test_done