t5601: add more test cases for IPV6

Test the parsing of literall IPV6 addresses more systematically: - with and without brackets (e.g. ::1 [::1]) - with brackets and port number: (e.g. [::1]:22) - with username (e.g. user@::1) - with username and brackets: Because user@[::1] was not supported on older Git version, [user@::1] had to be used as a workaround. Test that user@::1 user@[::1] and [user@::1] all do the same. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Torsten Bögershausen committed Feb 21, 2015 at 16:53 UTC 9f6976528b31356ee522d04aa31b86a3ba922f99
1 file changed +40 -17
t/t5601-clone.sh
+40 -17
@@ -301,11 +301,17 @@ expect_ssh () {
301 (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
302 ' &&
303 {
304 - case "$1" in
305 - none)
304 + case "$#" in
305 + 1)
306 ;;
307 - *)
307 + 2)
308 echo "ssh: $1 git-upload-pack '$2'"
309 + ;;
310 + 3)
311 + echo "ssh: $1 $2 git-upload-pack '$3'"
312 + ;;
313 + *)
314 + echo "ssh: $1 $2 git-upload-pack '$3' $4"
315 esac
316 } >"$TRASH_DIRECTORY/ssh-expect" &&
317 (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
@@ -336,7 +342,8 @@ counter=0
342 test_clone_url () {
343 counter=$(($counter + 1))
344 test_might_fail git clone "$1" tmp$counter &&
339 - expect_ssh "$2" "$3"
345 + shift &&
346 + expect_ssh "$@"
347 }
348
349 test_expect_success !MINGW 'clone c:temp is ssl' '
@@ -359,7 +366,7 @@ done
366 for repo in rep rep/home/project 123
367 do
368 test_expect_success "clone [::1]:$repo" '
362 - test_clone_url [::1]:$repo ::1 $repo
369 + test_clone_url [::1]:$repo ::1 "$repo"
370 '
371 done
372 #home directory
@@ -400,24 +407,40 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '
407 '
408
409 #IPv6
403 -test_expect_success 'clone ssh://[::1]/home/user/repo' '
404 - test_clone_url "ssh://[::1]/home/user/repo" "::1" "/home/user/repo"
405 -'
410 +for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
411 +do
412 + ehost=$(echo $tuah | tr -d "[]")
413 + test_expect_success "clone ssh://$tuah/home/user/repo" "
414 + test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
415 + "
416 +done
417
418 #IPv6 from home directory
408 -test_expect_success 'clone ssh://[::1]/~repo' '
409 - test_clone_url "ssh://[::1]/~repo" "::1" "~repo"
410 -'
419 +for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
420 +do
421 + euah=$(echo $tuah | tr -d "[]")
422 + test_expect_success "clone ssh://$tuah/~repo" "
423 + test_clone_url ssh://$tuah/~repo $euah '~repo'
424 + "
425 +done
426
427 #IPv6 with port number
413 -test_expect_success 'clone ssh://[::1]:22/home/user/repo' '
414 - test_clone_url "ssh://[::1]:22/home/user/repo" "-p 22 ::1" "/home/user/repo"
415 -'
428 +for tuah in [::1] user@[::1] [user@::1]
429 +do
430 + euah=$(echo $tuah | tr -d "[]")
431 + test_expect_success "clone ssh://$tuah:22/home/user/repo" "
432 + test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
433 + "
434 +done
435
436 #IPv6 from home directory with port number
418 -test_expect_success 'clone ssh://[::1]:22/~repo' '
419 - test_clone_url "ssh://[::1]:22/~repo" "-p 22 ::1" "~repo"
420 -'
437 +for tuah in [::1] user@[::1] [user@::1]
438 +do
439 + euah=$(echo $tuah | tr -d "[]")
440 + test_expect_success "clone ssh://$tuah:22/~repo" "
441 + test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
442 + "
443 +done
444
445 test_expect_success 'clone from a repository with two identical branches' '
446