summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2013-11-28 20:49:29 +0100
committerJunio C Hamano <gitster@pobox.com>2013-12-09 14:54:47 -0800
commit854aeb7beb85a7a3f05fc11daea7c8d2fed3a22c (patch)
tree6498ebf4206bbe2479d2b3ecf01286af8e0cd9a3 /t
parent5610b7c0c6957cf0b236b6fac087c1f4dc209376 (diff)
downloadgit-854aeb7beb85a7a3f05fc11daea7c8d2fed3a22c.tar.gz
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t5500-fetch-pack.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index d87ddf73b7..545dd7b8e1 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -531,5 +531,64 @@ test_expect_success 'shallow fetch with tags does not break the repository' '
git fsck
)
'
+check_prot_path () {
+ cat >expected <<-EOF &&
+ Diag: url=$1
+ Diag: protocol=$2
+ Diag: path=$3
+ EOF
+ git fetch-pack --diag-url "$1" | grep -v hostandport= >actual &&
+ test_cmp expected actual
+}
+
+check_prot_host_path () {
+ cat >expected <<-EOF &&
+ Diag: url=$1
+ Diag: protocol=$2
+ Diag: hostandport=$3
+ Diag: path=$4
+ EOF
+ git fetch-pack --diag-url "$1" >actual &&
+ test_cmp expected actual
+}
+
+for r in repo re:po re/po
+do
+ # git or ssh with scheme
+ for p in "ssh+git" "git+ssh" git ssh
+ do
+ for h in host host:12 [::1] [::1]:23
+ do
+ case "$p" in
+ *ssh*)
+ hh=$(echo $h | tr -d "[]")
+ pp=ssh
+ ;;
+ *)
+ hh=$h
+ pp=$p
+ ;;
+ esac
+ test_expect_success "fetch-pack --diag-url $p://$h/$r" '
+ check_prot_host_path $p://$h/$r $pp "$hh" "/$r"
+ '
+ # "/~" -> "~" conversion
+ test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
+ check_prot_host_path $p://$h/~$r $pp "$hh" "~$r"
+ '
+ done
+ done
+ # file with scheme
+ for p in file
+ do
+ test_expect_success "fetch-pack --diag-url $p://$h/$r" '
+ check_prot_path $p://$h/$r $p "/$r"
+ '
+ # No "/~" -> "~" conversion for file
+ test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
+ check_prot_path $p://$h/~$r $p "/~$r"
+ '
+ done
+done
test_done