fetch-pack: test cases for the new --stdin option
These test cases focus only on testing the parsing of refs on stdin, without bothering with the rest of the fetch-pack machinery. We pass in the refs using different combinations of command line and stdin and then we watch fetch-pack's stdout to see whether it prints all the refs we specified (but we ignore their order). Signed-off-by: Ivan Todoroski <grnch@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ivan Todoroski committed
Apr 2, 2012 at 17:16 UTC
b2a9f4da645365d20ffac85cf2a6b0898258fcdc
1 file changed
+66
t/t5500-fetch-pack.sh
+66
@@ -248,4 +248,70 @@ test_expect_success 'clone shallow object count' '
248
grep "^count: 52" count.shallow
249
'
250
251
+test_expect_success 'setup tests for the --stdin parameter' '
252
+ for head in C D E F
253
+ do
254
+ add $head
255
+ done &&
256
+ for head in A B C D E F
257
+ do
258
+ git tag $head $head
259
+ done &&
260
+ cat >input <<-\EOF
261
+ refs/heads/C
262
+ refs/heads/A
263
+ refs/heads/D
264
+ refs/tags/C
265
+ refs/heads/B
266
+ refs/tags/A
267
+ refs/heads/E
268
+ refs/tags/B
269
+ refs/tags/E
270
+ refs/tags/D
271
+ EOF
272
+ sort <input >expect &&
273
+ (
274
+ echo refs/heads/E &&
275
+ echo refs/tags/E &&
276
+ cat input
277
+ ) >input.dup
278
+'
279
+
280
+test_expect_success 'fetch refs from cmdline' '
281
+ (
282
+ cd client &&
283
+ git fetch-pack --no-progress .. $(cat ../input)
284
+ ) >output &&
285
+ cut -d " " -f 2 <output | sort >actual &&
286
+ test_cmp expect actual
287
+'
288
+
289
+test_expect_success 'fetch refs from stdin' '
290
+ (
291
+ cd client &&
292
+ git fetch-pack --stdin --no-progress .. <../input
293
+ ) >output &&
294
+ cut -d " " -f 2 <output | sort >actual &&
295
+ test_cmp expect actual
296
+'
297
+
298
+test_expect_success 'fetch mixed refs from cmdline and stdin' '
299
+ (
300
+ cd client &&
301
+ tail -n +5 ../input |
302
+ git fetch-pack --stdin --no-progress .. $(head -n 4 ../input)
303
+ ) >output &&
304
+ cut -d " " -f 2 <output | sort >actual &&
305
+ test_cmp expect actual
306
+'
307
+
308
+test_expect_success 'test duplicate refs from stdin' '
309
+ (
310
+ cd client &&
311
+ test_must_fail git fetch-pack --stdin --no-progress .. <../input.dup
312
+ ) >output &&
313
+ cut -d " " -f 2 <output | sort >actual &&
314
+ test_cmp expect actual
315
+'
316
+
317
test_done