t5519-push-alternates.sh [plain text]
#!/bin/sh
test_description='push to a repository that borrows from elsewhere'
. ./test-lib.sh
test_expect_success setup '
mkdir alice-pub &&
(
cd alice-pub &&
GIT_DIR=. git init
) &&
mkdir alice-work &&
(
cd alice-work &&
git init &&
>file &&
git add . &&
git commit -m initial &&
git push ../alice-pub master
) &&
mkdir bob-pub &&
(
cd bob-pub &&
GIT_DIR=. git init &&
mkdir -p objects/info &&
echo ../../alice-pub/objects >objects/info/alternates
) &&
git clone alice-pub bob-work &&
(
cd bob-work &&
git push ../bob-pub master
)
'
test_expect_success 'alice works and pushes' '
(
cd alice-work &&
echo more >file &&
git commit -a -m second &&
git push ../alice-pub :
)
'
test_expect_success 'bob fetches from alice, works and pushes' '
(
cd bob-work &&
git pull ../alice-pub master &&
echo more bob >file &&
git commit -a -m third &&
git push ../bob-pub :
) &&
(
cd bob-pub &&
second=$(git rev-parse HEAD^) &&
rm -f objects/info/alternates &&
test_must_fail git cat-file -t $second &&
echo ../../alice-pub/objects >objects/info/alternates
)
'
test_expect_success 'clean-up in case the previous failed' '
(
cd bob-pub &&
echo ../../alice-pub/objects >objects/info/alternates
)
'
test_expect_success 'alice works and pushes again' '
(
cd alice-work &&
echo more alice >file &&
git commit -a -m fourth &&
git push ../alice-pub :
)
'
test_expect_success 'bob works and pushes' '
(
cd bob-work &&
echo yet more bob >file &&
git commit -a -m fifth &&
git push ../bob-pub :
)
'
test_expect_success 'alice works and pushes yet again' '
(
cd alice-work &&
echo more and more alice >file &&
git commit -a -m sixth.1 &&
echo more and more alice >>file &&
git commit -a -m sixth.2 &&
echo more and more alice >>file &&
git commit -a -m sixth.3 &&
git push ../alice-pub :
)
'
test_expect_success 'bob works and pushes again' '
(
cd alice-pub &&
git cat-file commit master >../bob-work/commit
) &&
(
cd bob-work &&
git hash-object -t commit -w commit &&
echo even more bob >file &&
git commit -a -m seventh &&
git push ../bob-pub :
)
'
test_done