t5702: test fetch with multiple refspecs at a time
Extend the protocol v2 tests to also test fetches with multiple refspecs specified. This also covers the previously uncovered cases of fetching with prefix matching and fetching by SHA-1. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan committed
Jun 5, 2018 at 14:40 UTC
15cfc985e0e0ec6976637d66dd341743cc958373
1 file changed
+47
t/t5702-protocol-v2.sh
+47
@@ -359,6 +359,53 @@ test_expect_success 'default refspec is used to filter ref when fetchcing' '
359
grep "ref-prefix refs/tags/" log
360
'
361
362
+test_expect_success 'fetch supports various ways of have lines' '
363
+ rm -rf server client trace &&
364
+ git init server &&
365
+ test_commit -C server dwim &&
366
+ TREE=$(git -C server rev-parse HEAD^{tree}) &&
367
+ git -C server tag exact \
368
+ $(git -C server commit-tree -m a "$TREE") &&
369
+ git -C server tag dwim-unwanted \
370
+ $(git -C server commit-tree -m b "$TREE") &&
371
+ git -C server tag exact-unwanted \
372
+ $(git -C server commit-tree -m c "$TREE") &&
373
+ git -C server tag prefix1 \
374
+ $(git -C server commit-tree -m d "$TREE") &&
375
+ git -C server tag prefix2 \
376
+ $(git -C server commit-tree -m e "$TREE") &&
377
+ git -C server tag fetch-by-sha1 \
378
+ $(git -C server commit-tree -m f "$TREE") &&
379
+ git -C server tag completely-unrelated \
380
+ $(git -C server commit-tree -m g "$TREE") &&
381
+
382
+ git init client &&
383
+ GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
384
+ fetch "file://$(pwd)/server" \
385
+ dwim \
386
+ refs/tags/exact \
387
+ refs/tags/prefix*:refs/tags/prefix* \
388
+ "$(git -C server rev-parse fetch-by-sha1)" &&
389
+
390
+ # Ensure that the appropriate prefixes are sent (using a sample)
391
+ grep "fetch> ref-prefix dwim" trace &&
392
+ grep "fetch> ref-prefix refs/heads/dwim" trace &&
393
+ grep "fetch> ref-prefix refs/tags/prefix" trace &&
394
+
395
+ # Ensure that the correct objects are returned
396
+ git -C client cat-file -e $(git -C server rev-parse dwim) &&
397
+ git -C client cat-file -e $(git -C server rev-parse exact) &&
398
+ git -C client cat-file -e $(git -C server rev-parse prefix1) &&
399
+ git -C client cat-file -e $(git -C server rev-parse prefix2) &&
400
+ git -C client cat-file -e $(git -C server rev-parse fetch-by-sha1) &&
401
+ test_must_fail git -C client cat-file -e \
402
+ $(git -C server rev-parse dwim-unwanted) &&
403
+ test_must_fail git -C client cat-file -e \
404
+ $(git -C server rev-parse exact-unwanted) &&
405
+ test_must_fail git -C client cat-file -e \
406
+ $(git -C server rev-parse completely-unrelated)
407
+'
408
+
409
# Test protocol v2 with 'http://' transport
410
#
411
. "$TEST_DIRECTORY"/lib-httpd.sh