Skip to content

Commit cc969c8

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7253a02 commit cc969c8

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

t/t5551-http-fetch-smart.sh

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,35 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
213213
test_cmp expect_cookies.txt cookies_tail.txt
214214
'
215215

216-
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
217-
(
218-
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
219-
for i in `test_seq 50000`
216+
# create an arbitrary number of tags, numbered from tag-$1 to tag-$2
217+
create_tags () {
218+
rm -f marks &&
219+
for i in $(test_seq "$1" "$2")
220220
do
221-
echo "commit refs/heads/too-many-refs"
222-
echo "mark :$i"
223-
echo "committer git <[email protected]> $i +0000"
224-
echo "data 0"
225-
echo "M 644 inline bla.txt"
226-
echo "data 4"
227-
echo "bla"
221+
# don't use here-doc, because it requires a process
222+
# per loop iteration
223+
echo "commit refs/heads/too-many-refs-$1" &&
224+
echo "mark :$i" &&
225+
echo "committer git <[email protected]> $i +0000" &&
226+
echo "data 0" &&
227+
echo "M 644 inline bla.txt" &&
228+
echo "data 4" &&
229+
echo "bla" &&
228230
# make every commit dangling by always
229231
# rewinding the branch after each commit
230-
echo "reset refs/heads/too-many-refs"
231-
echo "from :1"
232+
echo "reset refs/heads/too-many-refs-$1" &&
233+
echo "from :$1"
232234
done | git fast-import --export-marks=marks &&
233235

234236
# now assign tags to all the dangling commits we created above
235237
tag=$(perl -e "print \"bla\" x 30") &&
236238
sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
239+
}
240+
241+
test_expect_success 'create 50,000 tags in the repo' '
242+
(
243+
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
244+
create_tags 1 50000
237245
)
238246
'
239247

0 commit comments

Comments
 (0)