1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 18:06:10 +02:00
git/t/t5501-fetch-push-alternates.sh
Johannes Schindelin 3275f4e886 t550*: adjust the references to the default branch name "main"
This trick was performed via

	$ (cd t &&
	   sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \
		-e 's/Master/Main/g' -- t550*.sh)

This allows us to define `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main`
for those tests.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19 15:44:18 -08:00

70 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
test_description='fetch/push involving alternates'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
count_objects () {
loose=0 inpack=0
eval "$(
git count-objects -v |
sed -n -e 's/^count: \(.*\)/loose=\1/p' \
-e 's/^in-pack: \(.*\)/inpack=\1/p'
)" &&
echo $(( $loose + $inpack ))
}
test_expect_success setup '
(
git init original &&
cd original &&
i=0 &&
while test $i -le 100
do
echo "$i" >count &&
git add count &&
git commit -m "$i" || exit
i=$(($i + 1))
done
) &&
(
git clone --reference=original "file://$(pwd)/original" one &&
cd one &&
echo Z >count &&
git add count &&
git commit -m Z &&
count_objects >../one.count
) &&
A=$(pwd)/original/.git/objects &&
git init receiver &&
echo "$A" >receiver/.git/objects/info/alternates &&
git init fetcher &&
echo "$A" >fetcher/.git/objects/info/alternates
'
test_expect_success 'pushing into a repository with the same alternate' '
(
cd one &&
git push ../receiver main:refs/heads/it
) &&
(
cd receiver &&
count_objects >../receiver.count
) &&
test_cmp one.count receiver.count
'
test_expect_success 'fetching from a repository with the same alternate' '
(
cd fetcher &&
git fetch ../one main:refs/heads/it &&
count_objects >../fetcher.count
) &&
test_cmp one.count fetcher.count
'
test_done