Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 854aeb7

Browse files
tboegigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5610b7c commit 854aeb7

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

t/t5500-fetch-pack.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,5 +531,64 @@ test_expect_success 'shallow fetch with tags does not break the repository' '
531531
git fsck
532532
)
533533
'
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
534593

535594
test_done

0 commit comments

Comments
 (0)