Git 1.7.6-rc3
[git/mjg.git] / t / t5501-fetch-push-alternates.sh
blobb5ced8483a8fc663eb53b514bbb56df92f217deb
1 #!/bin/sh
3 test_description='fetch/push involving alternates'
4 . ./test-lib.sh
6 count_objects () {
7 loose=0 inpack=0
8 eval "$(
9 git count-objects -v |
10 sed -n -e 's/^count: \(.*\)/loose=\1/p' \
11 -e 's/^in-pack: \(.*\)/inpack=\1/p'
12 )" &&
13 echo $(( $loose + $inpack ))
17 test_expect_success setup '
19 git init original &&
20 cd original &&
21 i=0 &&
22 while test $i -le 100
24 echo "$i" >count &&
25 git add count &&
26 git commit -m "$i" || exit
27 i=$(($i + 1))
28 done
29 ) &&
31 git clone --reference=original "file:///$(pwd)/original" one &&
32 cd one &&
33 echo Z >count &&
34 git add count &&
35 git commit -m Z &&
36 count_objects >../one.count
37 ) &&
38 A=$(pwd)/original/.git/objects &&
39 git init receiver &&
40 echo "$A" >receiver/.git/objects/info/alternates &&
41 git init fetcher &&
42 echo "$A" >fetcher/.git/objects/info/alternates
45 test_expect_success 'pushing into a repository with the same alternate' '
47 cd one &&
48 git push ../receiver master:refs/heads/it
49 ) &&
51 cd receiver &&
52 count_objects >../receiver.count
53 ) &&
54 test_cmp one.count receiver.count
57 test_expect_success 'fetching from a repository with the same alternate' '
59 cd fetcher &&
60 git fetch ../one master:refs/heads/it &&
61 count_objects >../fetcher.count
62 ) &&
63 test_cmp one.count fetcher.count
66 test_done