]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5501-fetch-push-alternates.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t5501-fetch-push-alternates.sh
CommitLineData
36cfda15
JH
1#!/bin/sh
2
3test_description='fetch/push involving alternates'
3275f4e8 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
36cfda15
JH
7. ./test-lib.sh
8
9count_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 ))
17}
18
19
20test_expect_success setup '
21 (
22 git init original &&
23 cd original &&
24 i=0 &&
25 while test $i -le 100
26 do
27 echo "$i" >count &&
28 git add count &&
29 git commit -m "$i" || exit
30 i=$(($i + 1))
31 done
32 ) &&
33 (
3a81f33c 34 git clone --reference=original "file://$(pwd)/original" one &&
36cfda15
JH
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
46'
47
48test_expect_success 'pushing into a repository with the same alternate' '
49 (
50 cd one &&
3275f4e8 51 git push ../receiver main:refs/heads/it
36cfda15
JH
52 ) &&
53 (
54 cd receiver &&
55 count_objects >../receiver.count
56 ) &&
57 test_cmp one.count receiver.count
58'
59
e52d7192 60test_expect_success 'fetching from a repository with the same alternate' '
36cfda15
JH
61 (
62 cd fetcher &&
3275f4e8 63 git fetch ../one main:refs/heads/it &&
36cfda15
JH
64 count_objects >../fetcher.count
65 ) &&
66 test_cmp one.count fetcher.count
67'
68
69test_done