t5551: factor out tag creation

One of our tests in t5551 creates a large number of tags,
and jumps through some hoops to do it efficiently. Let's
factor that out into a function so we can make other similar
tests.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2015-05-20 03:36:43 -04:00 committed by Junio C Hamano
parent 7253a02348
commit cc969c8dc1

View File

@ -213,27 +213,35 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
test_cmp expect_cookies.txt cookies_tail.txt test_cmp expect_cookies.txt cookies_tail.txt
' '
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' ' # create an arbitrary number of tags, numbered from tag-$1 to tag-$2
( create_tags () {
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && rm -f marks &&
for i in `test_seq 50000` for i in $(test_seq "$1" "$2")
do do
echo "commit refs/heads/too-many-refs" # don't use here-doc, because it requires a process
echo "mark :$i" # per loop iteration
echo "committer git <git@example.com> $i +0000" echo "commit refs/heads/too-many-refs-$1" &&
echo "data 0" echo "mark :$i" &&
echo "M 644 inline bla.txt" echo "committer git <git@example.com> $i +0000" &&
echo "data 4" echo "data 0" &&
echo "bla" echo "M 644 inline bla.txt" &&
echo "data 4" &&
echo "bla" &&
# make every commit dangling by always # make every commit dangling by always
# rewinding the branch after each commit # rewinding the branch after each commit
echo "reset refs/heads/too-many-refs" echo "reset refs/heads/too-many-refs-$1" &&
echo "from :1" echo "from :$1"
done | git fast-import --export-marks=marks && done | git fast-import --export-marks=marks &&
# now assign tags to all the dangling commits we created above # now assign tags to all the dangling commits we created above
tag=$(perl -e "print \"bla\" x 30") && tag=$(perl -e "print \"bla\" x 30") &&
sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
}
test_expect_success 'create 50,000 tags in the repo' '
(
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
create_tags 1 50000
) )
' '