Git 2.45
[git/gitster.git] / t / t5501-fetch-push-alternates.sh
blob66f19a4ef2b6ed2ac6dc2e133e1df7010cdcd98d
1 #!/bin/sh
3 test_description='fetch/push involving alternates'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 count_objects () {
10 loose=0 inpack=0
11 eval "$(
12 git count-objects -v |
13 sed -n -e 's/^count: \(.*\)/loose=\1/p' \
14 -e 's/^in-pack: \(.*\)/inpack=\1/p'
15 )" &&
16 echo $(( $loose + $inpack ))
20 test_expect_success setup '
22 git init original &&
23 cd original &&
24 i=0 &&
25 while test $i -le 100
27 echo "$i" >count &&
28 git add count &&
29 git commit -m "$i" || exit
30 i=$(($i + 1))
31 done
32 ) &&
34 git clone --reference=original "file://$(pwd)/original" one &&
35 cd one &&
36 echo Z >count &&
37 git add count &&
38 git commit -m Z &&
39 count_objects >../one.count
40 ) &&
41 A=$(pwd)/original/.git/objects &&
42 git init receiver &&
43 echo "$A" >receiver/.git/objects/info/alternates &&
44 git init fetcher &&
45 echo "$A" >fetcher/.git/objects/info/alternates
48 test_expect_success 'pushing into a repository with the same alternate' '
50 cd one &&
51 git push ../receiver main:refs/heads/it
52 ) &&
54 cd receiver &&
55 count_objects >../receiver.count
56 ) &&
57 test_cmp one.count receiver.count
60 test_expect_success 'fetching from a repository with the same alternate' '
62 cd fetcher &&
63 git fetch ../one main:refs/heads/it &&
64 count_objects >../fetcher.count
65 ) &&
66 test_cmp one.count fetcher.count
69 test_done