t5306-pack-nobase.sh [plain text]
#!/bin/sh
test_description='git-pack-object with missing base
'
. ./test-lib.sh
test_expect_success \
'setup base' \
'for a in a b c d e f g h i; do echo $a >>text; done &&
echo side >side &&
git update-index --add text side &&
A=$(echo A | git commit-tree $(git write-tree)) &&
echo m >>text &&
git update-index text &&
B=$(echo B | git commit-tree $(git write-tree) -p $A) &&
git update-ref HEAD $B
'
test_expect_success \
'setup patch_clone' \
'base_objects=$(pwd)/.git/objects &&
(mkdir patch_clone &&
cd patch_clone &&
git init &&
echo "$base_objects" >.git/objects/info/alternates &&
echo q >>text &&
git read-tree $B &&
git update-index text &&
git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) &&
rm .git/objects/info/alternates &&
git --git-dir=../.git cat-file commit $B |
git hash-object -t commit -w --stdin &&
git --git-dir=../.git cat-file tree "$B^{tree}" |
git hash-object -t tree -w --stdin
) &&
C=$(git --git-dir=patch_clone/.git rev-parse HEAD)
'
test_expect_success \
'indirectly clone patch_clone' \
'(mkdir user_clone &&
cd user_clone &&
git init &&
git pull ../.git &&
test $(git rev-parse HEAD) = $B &&
git pull ../patch_clone/.git &&
test $(git rev-parse HEAD) = $C
)
'
test_expect_success \
'clone of patch_clone is incomplete' \
'(mkdir user_direct &&
cd user_direct &&
git init &&
test_must_fail git fetch ../patch_clone/.git
)
'
test_done