From c8bae7493d2f2910b57f13ded012e86bdcfb0532 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:47:53 +0200 Subject: Adding upstream version 1:2.39.2. Signed-off-by: Daniel Baumann --- t/t5501-fetch-push-alternates.sh | 69 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 t/t5501-fetch-push-alternates.sh (limited to 't/t5501-fetch-push-alternates.sh') diff --git a/t/t5501-fetch-push-alternates.sh b/t/t5501-fetch-push-alternates.sh new file mode 100755 index 0000000..66f19a4 --- /dev/null +++ b/t/t5501-fetch-push-alternates.sh @@ -0,0 +1,69 @@ +#!/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 -- cgit v1.2.3