t5500: add test cases for diag-url

Add test cases using git fetch-pack --diag-url: - parse out host and path for URLs with a scheme (git:// file:// ssh://) - parse host names embedded by [] correctly - extract the port number, if present - separate URLs like "file" (which are local) from URLs like "host:repo" which should use ssh Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Torsten Bögershausen committed Nov 28, 2013 at 20:49 UTC 854aeb7beb85a7a3f05fc11daea7c8d2fed3a22c
1 file changed +59
t/t5500-fetch-pack.sh
+59
@@ -531,5 +531,64 @@ test_expect_success 'shallow fetch with tags does not break the repository' '
531 git fsck
532 )
533 '
534 +check_prot_path () {
535 + cat >expected <<-EOF &&
536 + Diag: url=$1
537 + Diag: protocol=$2
538 + Diag: path=$3
539 + EOF
540 + git fetch-pack --diag-url "$1" | grep -v hostandport= >actual &&
541 + test_cmp expected actual
542 +}
543 +
544 +check_prot_host_path () {
545 + cat >expected <<-EOF &&
546 + Diag: url=$1
547 + Diag: protocol=$2
548 + Diag: hostandport=$3
549 + Diag: path=$4
550 + EOF
551 + git fetch-pack --diag-url "$1" >actual &&
552 + test_cmp expected actual
553 +}
554 +
555 +for r in repo re:po re/po
556 +do
557 + # git or ssh with scheme
558 + for p in "ssh+git" "git+ssh" git ssh
559 + do
560 + for h in host host:12 [::1] [::1]:23
561 + do
562 + case "$p" in
563 + *ssh*)
564 + hh=$(echo $h | tr -d "[]")
565 + pp=ssh
566 + ;;
567 + *)
568 + hh=$h
569 + pp=$p
570 + ;;
571 + esac
572 + test_expect_success "fetch-pack --diag-url $p://$h/$r" '
573 + check_prot_host_path $p://$h/$r $pp "$hh" "/$r"
574 + '
575 + # "/~" -> "~" conversion
576 + test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
577 + check_prot_host_path $p://$h/~$r $pp "$hh" "~$r"
578 + '
579 + done
580 + done
581 + # file with scheme
582 + for p in file
583 + do
584 + test_expect_success "fetch-pack --diag-url $p://$h/$r" '
585 + check_prot_path $p://$h/$r $p "/$r"
586 + '
587 + # No "/~" -> "~" conversion for file
588 + test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
589 + check_prot_path $p://$h/~$r $p "/~$r"
590 + '
591 + done
592 +done
593
594 test_done