3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Testing multi_ack pack fetching'
10 # Test fetch-pack/upload-pack pair.
12 # Some convenience functions
17 branch=`echo $name | sed -e 's/^\(.\).*$/\1/'` &&
22 parents="$parents -p $1" &&
26 echo "$text" > test.txt &&
27 git update-index --add test.txt &&
28 tree=$(git write-tree) &&
29 # make sure timestamps are in correct order
31 commit=$(echo "$text" | git commit-tree $tree $parents) &&
32 eval "$name=$commit; export $name" &&
33 echo $commit > .git/refs/heads/$branch &&
34 eval ${branch}TIP=$commit
41 test_expect_success "$number pull" '
44 git fetch-pack -k -v .. $heads &&
48 echo $ATIP > .git/refs/heads/A;;
51 echo $BTIP > .git/refs/heads/B;;
53 git symbolic-ref HEAD refs/heads/`echo $heads \
54 | sed -e "s/^\(.\).*$/\1/"` &&
58 mv .git/objects/pack/pack-* . &&
59 p=`ls -1 pack-*.pack` &&
60 git unpack-objects <$p &&
63 idx=`echo pack-*.idx` &&
64 pack_count=`git show-index <$idx | wc -l` &&
65 test $pack_count = $count &&
71 # Here begins the actual testing
73 # A1 - ... - A20 - A21
77 # client pulls A20, B1. Then tracks only B. Then pulls A.
79 test_expect_success 'setup' '
84 git config transfer.unpacklimit 0
89 while [ $cur -le 10 ]; do
90 add A$cur $(eval echo \$A$prev) &&
95 echo $ATIP > .git/refs/heads/A &&
96 echo $BTIP > .git/refs/heads/B &&
97 git symbolic-ref HEAD refs/heads/B
100 pull_to_client 1st "refs/heads/B refs/heads/A" $((11*3))
102 test_expect_success 'post 1st pull setup' '
106 while [ $cur -le 65 ]; do
107 add B$cur $(eval echo \$B$prev) &&
113 pull_to_client 2nd "refs/heads/B" $((64*3))
115 pull_to_client 3rd "refs/heads/A" $((1*3))
117 test_expect_success 'single branch clone' '
118 git clone --single-branch "file://$(pwd)/." singlebranch
121 test_expect_success 'single branch object count' '
122 GIT_DIR=singlebranch/.git git count-objects -v |
123 grep "^in-pack:" > count.singlebranch &&
124 echo "in-pack: 198" >expected &&
125 test_cmp expected count.singlebranch
128 test_expect_success 'clone shallow' '
129 git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow
132 test_expect_success 'clone shallow object count' '
137 grep "^in-pack: 18" count.shallow
140 test_expect_success 'clone shallow object count (part 2)' '
141 sed -e "/^in-pack:/d" -e "/^packs:/d" -e "/^size-pack:/d" \
142 -e "/: 0$/d" count.shallow > count_output &&
143 ! test -s count_output
146 test_expect_success 'fsck in shallow repo' '
153 test_expect_success 'simple fetch in shallow repo' '
160 test_expect_success 'no changes expected' '
164 ) > count.shallow.2 &&
165 cmp count.shallow count.shallow.2
168 test_expect_success 'fetch same depth in shallow repo' '
175 test_expect_success 'no changes expected' '
179 ) > count.shallow.3 &&
180 cmp count.shallow count.shallow.3
183 test_expect_success 'add two more' '
188 test_expect_success 'pull in shallow repo' '
195 test_expect_success 'clone shallow object count' '
200 grep "^count: 6" count.shallow
203 test_expect_success 'add two more (part 2)' '
208 test_expect_success 'deepening pull in shallow repo' '
211 git pull --depth 4 .. B
215 test_expect_success 'clone shallow object count' '
220 grep "^count: 12" count.shallow
223 test_expect_success 'deepening fetch in shallow repo' '
226 git fetch --depth 4 .. A:A
230 test_expect_success 'clone shallow object count' '
235 grep "^count: 18" count.shallow
238 test_expect_success 'pull in shallow repo with missing merge base' '
241 test_must_fail git pull --depth 4 .. A
245 test_expect_success 'additional simple shallow deepenings' '
248 git fetch --depth=8 &&
249 git fetch --depth=10 &&
254 test_expect_success 'clone shallow object count' '
259 grep "^count: 52" count.shallow
262 test_expect_success 'clone shallow without --no-single-branch' '
263 git clone --depth 1 "file://$(pwd)/." shallow2
266 test_expect_success 'clone shallow object count' '
270 ) > count.shallow2 &&
271 grep "^in-pack: 6" count.shallow2
274 test_expect_success 'clone shallow with --branch' '
275 git clone --depth 1 --branch A "file://$(pwd)/." shallow3
278 test_expect_success 'clone shallow object count' '
279 echo "in-pack: 12" > count3.expected &&
280 GIT_DIR=shallow3/.git git count-objects -v |
281 grep "^in-pack" > count3.actual &&
282 test_cmp count3.expected count3.actual
285 test_expect_success 'clone shallow with detached HEAD' '
286 git checkout HEAD^ &&
287 git clone --depth 1 "file://$(pwd)/." shallow5 &&
289 GIT_DIR=shallow5/.git git rev-parse HEAD >actual &&
290 git rev-parse HEAD^ >expected &&
291 test_cmp expected actual
294 test_expect_success 'shallow clone pulling tags' '
295 git tag -a -m A TAGA1 A &&
296 git tag -a -m B TAGB1 B &&
299 git clone --depth 1 "file://$(pwd)/." shallow6 &&
301 cat >taglist.expected <<\EOF &&
305 GIT_DIR=shallow6/.git git tag -l >taglist.actual &&
306 test_cmp taglist.expected taglist.actual &&
308 echo "in-pack: 7" > count6.expected &&
309 GIT_DIR=shallow6/.git git count-objects -v |
310 grep "^in-pack" > count6.actual &&
311 test_cmp count6.expected count6.actual
314 test_expect_success 'shallow cloning single tag' '
315 git clone --depth 1 --branch=TAGB1 "file://$(pwd)/." shallow7 &&
316 cat >taglist.expected <<\EOF &&
320 GIT_DIR=shallow7/.git git tag -l >taglist.actual &&
321 test_cmp taglist.expected taglist.actual &&
323 echo "in-pack: 7" > count7.expected &&
324 GIT_DIR=shallow7/.git git count-objects -v |
325 grep "^in-pack" > count7.actual &&
326 test_cmp count7.expected count7.actual