svn: allow branches outside of refs/remotes
[git.git] / t / t5500-fetch-pack.sh
bloba8c2ca2a78dd54f69230cb443eff1d6e82336f0a
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 'add two more' '
143 add B66 $B65 &&
144 add B67 $B66
147 test_expect_success 'pull in shallow repo' '
149 cd shallow &&
150 git pull .. B
154 test_expect_success 'clone shallow object count' '
156 cd shallow &&
157 git count-objects -v
158 ) > count.shallow &&
159 grep "^count: 6" count.shallow
162 test_expect_success 'add two more (part 2)' '
163 add B68 $B67 &&
164 add B69 $B68
167 test_expect_success 'deepening pull in shallow repo' '
169 cd shallow &&
170 git pull --depth 4 .. B
174 test_expect_success 'clone shallow object count' '
176 cd shallow &&
177 git count-objects -v
178 ) > count.shallow &&
179 grep "^count: 12" count.shallow
182 test_expect_success 'deepening fetch in shallow repo' '
184 cd shallow &&
185 git fetch --depth 4 .. A:A
189 test_expect_success 'clone shallow object count' '
191 cd shallow &&
192 git count-objects -v
193 ) > count.shallow &&
194 grep "^count: 18" count.shallow
197 test_expect_success 'pull in shallow repo with missing merge base' '
199 cd shallow &&
200 test_must_fail git pull --depth 4 .. A
204 test_done