2011-05-08 10:47:35 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (c) 2011, Google Inc.
|
|
|
|
|
|
|
|
test_description='adding and checking out large blobs'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
2012-03-07 11:54:16 +01:00
|
|
|
# clone does not allow us to pass core.bigfilethreshold to
|
|
|
|
# new repos, so set core.bigfilethreshold globally
|
|
|
|
git config --global core.bigfilethreshold 200k &&
|
2011-10-28 23:48:40 +02:00
|
|
|
echo X | dd of=large1 bs=1k seek=2000 &&
|
|
|
|
echo X | dd of=large2 bs=1k seek=2000 &&
|
|
|
|
echo X | dd of=large3 bs=1k seek=2000 &&
|
2012-03-07 11:54:16 +01:00
|
|
|
echo Y | dd of=huge bs=1k seek=2500 &&
|
2014-08-26 17:23:22 +02:00
|
|
|
GIT_ALLOC_LIMIT=1500k &&
|
2012-03-07 11:54:16 +01:00
|
|
|
export GIT_ALLOC_LIMIT
|
2011-05-08 10:47:35 +02:00
|
|
|
'
|
|
|
|
|
2011-10-28 23:48:40 +02:00
|
|
|
test_expect_success 'add a large file or two' '
|
|
|
|
git add large1 huge large2 &&
|
|
|
|
# make sure we got a single packfile and no loose objects
|
|
|
|
bad= count=0 idx= &&
|
|
|
|
for p in .git/objects/pack/pack-*.pack
|
|
|
|
do
|
|
|
|
count=$(( $count + 1 ))
|
|
|
|
if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
|
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
bad=t
|
|
|
|
done &&
|
|
|
|
test -z "$bad" &&
|
|
|
|
test $count = 1 &&
|
|
|
|
cnt=$(git show-index <"$idx" | wc -l) &&
|
|
|
|
test $cnt = 2 &&
|
|
|
|
for l in .git/objects/??/??????????????????????????????????????
|
|
|
|
do
|
|
|
|
test -f "$l" || continue
|
|
|
|
bad=t
|
|
|
|
done &&
|
|
|
|
test -z "$bad" &&
|
|
|
|
|
|
|
|
# attempt to add another copy of the same
|
|
|
|
git add large3 &&
|
|
|
|
bad= count=0 &&
|
|
|
|
for p in .git/objects/pack/pack-*.pack
|
|
|
|
do
|
|
|
|
count=$(( $count + 1 ))
|
|
|
|
if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
|
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
bad=t
|
|
|
|
done &&
|
|
|
|
test -z "$bad" &&
|
|
|
|
test $count = 1
|
2011-05-08 10:47:35 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'checkout a large file' '
|
2011-10-28 23:48:40 +02:00
|
|
|
large1=$(git rev-parse :large1) &&
|
|
|
|
git update-index --add --cacheinfo 100644 $large1 another &&
|
2011-05-08 10:47:35 +02:00
|
|
|
git checkout another &&
|
2011-10-28 23:48:40 +02:00
|
|
|
cmp large1 another ;# this must not be test_cmp
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'packsize limit' '
|
|
|
|
test_create_repo mid &&
|
|
|
|
(
|
|
|
|
cd mid &&
|
|
|
|
git config core.bigfilethreshold 64k &&
|
|
|
|
git config pack.packsizelimit 256k &&
|
|
|
|
|
|
|
|
# mid1 and mid2 will fit within 256k limit but
|
|
|
|
# appending mid3 will bust the limit and will
|
|
|
|
# result in a separate packfile.
|
|
|
|
test-genrandom "a" $(( 66 * 1024 )) >mid1 &&
|
|
|
|
test-genrandom "b" $(( 80 * 1024 )) >mid2 &&
|
|
|
|
test-genrandom "c" $(( 128 * 1024 )) >mid3 &&
|
|
|
|
git add mid1 mid2 mid3 &&
|
|
|
|
|
|
|
|
count=0
|
|
|
|
for pi in .git/objects/pack/pack-*.idx
|
|
|
|
do
|
|
|
|
test -f "$pi" && count=$(( $count + 1 ))
|
|
|
|
done &&
|
|
|
|
test $count = 2 &&
|
|
|
|
|
|
|
|
(
|
|
|
|
git hash-object --stdin <mid1
|
|
|
|
git hash-object --stdin <mid2
|
|
|
|
git hash-object --stdin <mid3
|
|
|
|
) |
|
|
|
|
sort >expect &&
|
|
|
|
|
|
|
|
for pi in .git/objects/pack/pack-*.idx
|
|
|
|
do
|
|
|
|
git show-index <"$pi"
|
|
|
|
done |
|
|
|
|
sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
|
|
|
|
sort >actual &&
|
|
|
|
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
2011-05-08 10:47:35 +02:00
|
|
|
'
|
|
|
|
|
2012-03-07 11:54:16 +01:00
|
|
|
test_expect_success 'diff --raw' '
|
|
|
|
git commit -q -m initial &&
|
|
|
|
echo modified >>large1 &&
|
|
|
|
git add large1 &&
|
|
|
|
git commit -q -m modified &&
|
|
|
|
git diff --raw HEAD^
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'hash-object' '
|
|
|
|
git hash-object large1
|
|
|
|
'
|
|
|
|
|
2012-03-07 11:54:17 +01:00
|
|
|
test_expect_success 'cat-file a large file' '
|
2012-03-07 11:54:16 +01:00
|
|
|
git cat-file blob :large1 >/dev/null
|
|
|
|
'
|
|
|
|
|
2012-03-07 11:54:17 +01:00
|
|
|
test_expect_success 'cat-file a large file from a tag' '
|
2012-03-07 11:54:16 +01:00
|
|
|
git tag -m largefile largefiletag :large1 &&
|
|
|
|
git cat-file blob largefiletag >/dev/null
|
|
|
|
'
|
|
|
|
|
2012-03-07 11:54:19 +01:00
|
|
|
test_expect_success 'git-show a large file' '
|
2012-03-07 11:54:16 +01:00
|
|
|
git show :large1 >/dev/null
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2012-05-23 16:09:47 +02:00
|
|
|
test_expect_success 'index-pack' '
|
2014-04-28 14:57:37 +02:00
|
|
|
git clone file://"$(pwd)"/.git foo &&
|
2012-05-23 16:09:47 +02:00
|
|
|
GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack
|
|
|
|
'
|
|
|
|
|
2012-03-07 11:54:21 +01:00
|
|
|
test_expect_success 'repack' '
|
2012-03-07 11:54:16 +01:00
|
|
|
git repack -ad
|
|
|
|
'
|
|
|
|
|
2012-05-26 12:28:01 +02:00
|
|
|
test_expect_success 'pack-objects with large loose object' '
|
2014-04-28 14:57:37 +02:00
|
|
|
SHA1=$(git hash-object huge) &&
|
2012-05-26 12:28:01 +02:00
|
|
|
test_create_repo loose &&
|
|
|
|
echo $SHA1 | git pack-objects --stdout |
|
|
|
|
GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
|
|
|
|
echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
|
|
|
|
test_create_repo packed &&
|
|
|
|
mv pack-* packed/.git/objects/pack &&
|
|
|
|
GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
|
|
|
|
cmp huge actual
|
|
|
|
'
|
|
|
|
|
2012-05-03 03:51:04 +02:00
|
|
|
test_expect_success 'tar achiving' '
|
|
|
|
git archive --format=tar HEAD >/dev/null
|
|
|
|
'
|
|
|
|
|
2012-05-03 03:51:07 +02:00
|
|
|
test_expect_success 'zip achiving, store only' '
|
|
|
|
git archive --format=zip -0 HEAD >/dev/null
|
|
|
|
'
|
|
|
|
|
2012-05-03 03:51:08 +02:00
|
|
|
test_expect_success 'zip achiving, deflate' '
|
|
|
|
git archive --format=zip HEAD >/dev/null
|
|
|
|
'
|
|
|
|
|
2011-05-08 10:47:35 +02:00
|
|
|
test_done
|