t0005: fix broken &&-chains
[gitweb.git] / t / t5500-fetch-pack.sh
index a80584ea0eaba854ff21318e3c9646f72325bee7..692d71738b15eac20029a7ce667db9d398d944d0 100755 (executable)
@@ -393,6 +393,17 @@ test_expect_success 'fetch in shallow repo unreachable shallow objects' '
                git fsck --no-dangling
        )
 '
+test_expect_success 'fetch creating new shallow root' '
+       (
+               git clone "file://$(pwd)/." shallow10 &&
+               git commit --allow-empty -m empty &&
+               cd shallow10 &&
+               git fetch --depth=1 --progress 2>actual &&
+               # This should fetch only the empty commit, no tree or
+               # blob objects
+               grep "remote: Total 1" actual
+       )
+'
 
 test_expect_success 'setup tests for the --stdin parameter' '
        for head in C D E F
@@ -403,7 +414,7 @@ test_expect_success 'setup tests for the --stdin parameter' '
        do
                git tag $head $head
        done &&
-       cat >input <<-\EOF
+       cat >input <<-\EOF &&
        refs/heads/C
        refs/heads/A
        refs/heads/D
@@ -520,5 +531,107 @@ 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_port_path () {
+       local diagport
+       case "$2" in
+               *ssh*)
+               pp=ssh
+               uah=userandhost
+               ehost=$(echo $3 | tr -d "[]")
+               diagport="Diag: port=$4"
+               ;;
+               *)
+               pp=$p
+               uah=hostandport
+               ehost=$(echo $3$4 | sed -e "s/22$/:22/" -e "s/NONE//")
+               diagport=""
+               ;;
+       esac
+       cat >exp <<-EOF &&
+       Diag: url=$1
+       Diag: protocol=$pp
+       Diag: $uah=$ehost
+       $diagport
+       Diag: path=$5
+       EOF
+       grep -v "^$" exp >expected
+       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 user@host user@[::1] user@::1
+               do
+                       test_expect_success "fetch-pack --diag-url $p://$h/$r" '
+                               check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r"
+                       '
+                       # "/~" -> "~" conversion
+                       test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
+                               check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r"
+                       '
+               done
+               for h in host User@host User@[::1]
+               do
+                       test_expect_success "fetch-pack --diag-url $p://$h:22/$r" '
+                               check_prot_host_port_path $p://$h:22/$r $p "$h" 22 "/$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
+       # file without scheme
+       for h in nohost nohost:12 [::1] [::1]:23 [ [:aa
+       do
+               test_expect_success "fetch-pack --diag-url ./$h:$r" '
+                       check_prot_path ./$h:$r $p "./$h:$r"
+               '
+               # No "/~" -> "~" conversion for file
+               test_expect_success "fetch-pack --diag-url ./$p:$h/~$r" '
+               check_prot_path ./$p:$h/~$r $p "./$p:$h/~$r"
+               '
+       done
+       #ssh without scheme
+       p=ssh
+       for h in host [::1]
+       do
+               test_expect_success "fetch-pack --diag-url $h:$r" '
+                       check_prot_host_port_path $h:$r $p "$h" NONE "$r"
+               '
+               # Do "/~" -> "~" conversion
+               test_expect_success "fetch-pack --diag-url $h:/~$r" '
+                       check_prot_host_port_path $h:/~$r $p "$h" NONE "~$r"
+               '
+       done
+done
+
+test_expect_success MINGW 'fetch-pack --diag-url file://c:/repo' '
+       check_prot_path file://c:/repo file c:/repo
+'
+test_expect_success MINGW 'fetch-pack --diag-url c:repo' '
+       check_prot_path c:repo file c:repo
+'
 
 test_done