From 379a03ad8194192ab7b2910ec3326a981971fda1 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Fri, 7 Sep 2012 00:41:04 +0200 Subject: [PATCH] t0060: verify that real_path() removes extra slashes Adjusted for Windows by: Johannes Sixt Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- t/t0060-path-utils.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 30361f94a..e40f764d5 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -158,6 +158,24 @@ test_expect_success POSIX 'real path works on absolute paths' ' test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")" ' +test_expect_success POSIX 'real path removes extra leading slashes' ' + nopath="hopefully-absent-path" && + test "/" = "$(test-path-utils real_path "///")" && + test "/$nopath" = "$(test-path-utils real_path "///$nopath")" && + # Find an existing top-level directory for the remaining tests: + d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && + test "$d" = "$(test-path-utils real_path "//$d")" && + test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")" +' + +test_expect_success 'real path removes other extra slashes' ' + nopath="hopefully-absent-path" && + # Find an existing top-level directory for the remaining tests: + d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && + test "$d" = "$(test-path-utils real_path "$d///")" && + test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")" +' + test_expect_success SYMLINKS 'real path works on symlinks' ' mkdir first && ln -s ../.git first/.git && -- 2.26.2