git-notes: Run partial expensive test everywhere
[alt-git.git] / t / t5500-fetch-pack.sh
blob18376d66081759c6a4959a2d8bc47ca441364660
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Testing multi_ack pack fetching'
8 . ./test-lib.sh
10 # Test fetch-pack/upload-pack pair.
12 # Some convenience functions
14 add () {
15 name=$1 &&
16 text="$@" &&
17 branch=`echo $name | sed -e 's/^\(.\).*$/\1/'` &&
18 parents="" &&
20 shift &&
21 while test $1; do
22 parents="$parents -p $1" &&
23 shift
24 done &&
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
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 &&
34 eval ${branch}TIP=$commit
37 pull_to_client () {
38 number=$1 &&
39 heads=$2 &&
40 count=$3 &&
41 test_expect_success "$number pull" '
43 cd client &&
44 git fetch-pack -k -v .. $heads &&
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/"` &&
56 git fsck --full &&
58 mv .git/objects/pack/pack-* . &&
59 p=`ls -1 pack-*.pack` &&
60 git unpack-objects <$p &&
61 git fsck --full &&
63 idx=`echo pack-*.idx` &&
64 pack_count=`git show-index <$idx | wc -l` &&
65 test $pack_count = $count &&
66 rm -f pack-*
71 # Here begins the actual testing
73 # A1 - ... - A20 - A21
74 # \
75 # B1 - B2 - .. - B70
77 # client pulls A20, B1. Then tracks only B. Then pulls A.
79 test_expect_success 'setup' '
80 mkdir client &&
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 &&
94 add B1 $A1
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 "B A" $((11*3))
102 test_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
113 pull_to_client 2nd "B" $((64*3))
115 pull_to_client 3rd "A" $((1*3))
117 test_expect_success 'clone shallow' '
118 git clone --depth 2 "file://$(pwd)/." shallow
121 test_expect_success 'clone shallow object count' '
123 cd shallow &&
124 git count-objects -v
125 ) > count.shallow &&
126 grep "^in-pack: 18" count.shallow
129 test_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
135 test_expect_success 'fsck in shallow repo' '
137 cd shallow &&
138 git fsck --full
142 test_expect_success 'simple fetch in shallow repo' '
144 cd shallow &&
145 git fetch
149 test_expect_success 'no changes expected' '
151 cd shallow &&
152 git count-objects -v
153 ) > count.shallow.2 &&
154 cmp count.shallow count.shallow.2
157 test_expect_success 'fetch same depth in shallow repo' '
159 cd shallow &&
160 git fetch --depth=2
164 test_expect_success 'no changes expected' '
166 cd shallow &&
167 git count-objects -v
168 ) > count.shallow.3 &&
169 cmp count.shallow count.shallow.3
172 test_expect_success 'add two more' '
173 add B66 $B65 &&
174 add B67 $B66
177 test_expect_success 'pull in shallow repo' '
179 cd shallow &&
180 git pull .. B
184 test_expect_success 'clone shallow object count' '
186 cd shallow &&
187 git count-objects -v
188 ) > count.shallow &&
189 grep "^count: 6" count.shallow
192 test_expect_success 'add two more (part 2)' '
193 add B68 $B67 &&
194 add B69 $B68
197 test_expect_success 'deepening pull in shallow repo' '
199 cd shallow &&
200 git pull --depth 4 .. B
204 test_expect_success 'clone shallow object count' '
206 cd shallow &&
207 git count-objects -v
208 ) > count.shallow &&
209 grep "^count: 12" count.shallow
212 test_expect_success 'deepening fetch in shallow repo' '
214 cd shallow &&
215 git fetch --depth 4 .. A:A
219 test_expect_success 'clone shallow object count' '
221 cd shallow &&
222 git count-objects -v
223 ) > count.shallow &&
224 grep "^count: 18" count.shallow
227 test_expect_success 'pull in shallow repo with missing merge base' '
229 cd shallow &&
230 test_must_fail git pull --depth 4 .. A
234 test_expect_success 'additional simple shallow deepenings' '
236 cd shallow &&
237 git fetch --depth=8 &&
238 git fetch --depth=10 &&
239 git fetch --depth=11
243 test_expect_success 'clone shallow object count' '
245 cd shallow &&
246 git count-objects -v
247 ) > count.shallow &&
248 grep "^count: 52" count.shallow
251 test_done