# [PATCH v6 06/10] t5500: Test case for diag-url

2 messages from 2013-11-21 to 2013-11-21. Participants: Torsten Bögershausen, Junio C Hamano.
Thread: https://gitlist.dev/t/35383

## Torsten Bögershausen, 2013-11-21 20:40

Subject: [PATCH v6 06/10] t5500: Test case for diag-url
Message-ID: <201311212140.58804.tboegi@web.de>
URL: https://gitlist.dev/e/201311212140.58804.tboegi%40web.de

```
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
- seperate URLs like "file" (which are local)
  from URLs like "host:repo" which should use ssh
---
 t/t5500-fetch-pack.sh | 72 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 56 insertions(+), 16 deletions(-)

diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 9136f2a..7f55b95 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -533,7 +533,7 @@ test_expect_success 'shallow fetch with tags does not break the repository' '
 '
 check_prot_path() {
 	> actual &&
-	(git fetch-pack --diag-url "$1" 2>&1 1>stdout) | grep -v host= >actual &&
+	(git fetch-pack --diag-url  "$1" 2>&1 1>stdout) | grep -v host= >actual &&
 	echo "Diag: url=$1" >expected &&
 	echo "Diag: protocol=$2" >>expected &&
 	echo "Diag: path=$3" >>expected &&
@@ -542,7 +542,7 @@ check_prot_path() {
 
 check_prot_host_path() {
 	> actual &&
-	git fetch-pack --diag-url "$1" 2>actual &&
+	git fetch-pack --diag-url  "$1" 2>actual &&
 	echo "Diag: url=$1" >expected &&
 	echo "Diag: protocol=$2" >>expected &&
 	echo "Diag: host=$3" >>expected &&
@@ -564,29 +564,69 @@ do
 				hh=$h
 				pp=$p
 			fi
-			test_expect_success "fetch-pack $p://$h/$r" '
+			test_expect_success "fetch-pack --diag-url $p://$h/$r" '
 				check_prot_host_path $p://$h/$r $pp "$hh" "/$r"
 			'
-			# "/~" -> "~" conversion for git
-			test_expect_success "fetch-pack $p://$h/~$r" '
+			# "/~" -> "~" conversion
+			test_expect_success "fetch-pack --diag-url $p://$h/~$r" '
 				check_prot_host_path $p://$h/~$r $pp "$hh" "~$r"
 			'
 		done
 	done
+	p=file
 	# file with scheme
-	for p in file
+	for h in "" host host:12 [::1] [::1]:23
 	do
-		for h in "" host host:12 [::1] [::1]:23
-		do
-			test_expect_success "fetch-pack $p://$h/$r" '
-				check_prot_path $p://$h/$r $p "/$r"
-			'
-			# No "/~" -> "~" conversion for file
-			test_expect_success "fetch-pack $p://$h/~$r" '
-				check_prot_path $p://$h/~$r $p "/~$r"
-			'
-		done
+		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
+		hh=$(echo $h | tr -d "[]")
+		test_expect_success "fetch-pack --diag-url $h:$r" '
+			check_prot_path $h:$r $p "$r"
+		'
 	done
+	h=host
+	hh=host
+	# "/~" -> "~" conversion
+	test_expect_failure "fetch-pack --diag-url $h:/~$r" '
+		check_prot_host_path $h:/~$r $p "$hh" "~$r"
+	'
+	h=[::1]
+	hh=$(echo $h | tr -d "[]")
+	# "/~" -> "~" conversion
+	test_expect_success "fetch-pack --diag-url $h:/~$r" '
+		check_prot_host_path $h:/~$r $p "$hh" "~$r"
+	'
 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 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
-- 
1.8.4.457.g424cb08

```

## Junio C Hamano, 2013-11-21 23:27

Subject: Re: [PATCH v6 06/10] t5500: Test case for diag-url
Message-ID: <xmqqfvqp2v50.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqfvqp2v50.fsf%40gitster.dls.corp.google.com
In-Reply-To: <201311212140.58804.tboegi@web.de>

```
Torsten Bögershausen <tboegi@web.de> writes:

> 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
> - seperate URLs like "file" (which are local)
>   from URLs like "host:repo" which should use ssh
> ---
>  t/t5500-fetch-pack.sh | 72 +++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 56 insertions(+), 16 deletions(-)
>
> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> index 9136f2a..7f55b95 100755
> --- a/t/t5500-fetch-pack.sh
> +++ b/t/t5500-fetch-pack.sh
> @@ -533,7 +533,7 @@ test_expect_success 'shallow fetch with tags does not break the repository' '
>  '
>  check_prot_path() {
>  	> actual &&
> -	(git fetch-pack --diag-url "$1" 2>&1 1>stdout) | grep -v host= >actual &&
> +	(git fetch-pack --diag-url  "$1" 2>&1 1>stdout) | grep -v host= >actual &&

What is this change about???

>  	echo "Diag: url=$1" >expected &&
>  	echo "Diag: protocol=$2" >>expected &&
>  	echo "Diag: path=$3" >>expected &&
> @@ -542,7 +542,7 @@ check_prot_path() {
>  
>  check_prot_host_path() {
>  	> actual &&
> -	git fetch-pack --diag-url "$1" 2>actual &&
> +	git fetch-pack --diag-url  "$1" 2>actual &&

Likewise...

> @@ -564,29 +564,69 @@ do
>  				hh=$h
>  				pp=$p
>  			fi
> -			test_expect_success "fetch-pack $p://$h/$r" '
> +			test_expect_success "fetch-pack --diag-url $p://$h/$r" '
>  				check_prot_host_path $p://$h/$r $pp "$hh" "/$r"
>  			'
> -			# "/~" -> "~" conversion for git
> -			test_expect_success "fetch-pack $p://$h/~$r" '
> +			# "/~" -> "~" conversion
> +			test_expect_success "fetch-pack --diag-url $p://$h/~$r" '

Is this part, especially the "s/ for git//" bit, an "oops, the
earlier one was wrong" fix to [05/10]?  If so, please don't.
Instead, please get it right in that patch before sending the series
out.

```
