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>
Jeff King committed
May 20, 2015 at 03:36 UTC
cc969c8dc1cfd1f60b1dab8ee3117172d9d1bb4f
1 file changed
+21
-13
t/t5551-http-fetch-smart.sh
+21
-13
@@ -213,27 +213,35 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
213
test_cmp expect_cookies.txt cookies_tail.txt
214
'
215
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")
220
do
221
- echo "commit refs/heads/too-many-refs"
222
- echo "mark :$i"
223
- echo "committer git <git@example.com> $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 <git@example.com> $i +0000" &&
226
+ echo "data 0" &&
227
+ echo "M 644 inline bla.txt" &&
228
+ echo "data 4" &&
229
+ echo "bla" &&
230
# make every commit dangling by always
231
# 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"
234
done | git fast-import --export-marks=marks &&
235
236
# now assign tags to all the dangling commits we created above
237
tag=$(perl -e "print \"bla\" x 30") &&
238
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
245
)
246
'
247