diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2012-09-07 00:41:04 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-06 16:19:58 -0700 |
commit | 379a03ad8194192ab7b2910ec3326a981971fda1 (patch) | |
tree | 047aecb8dd15d85efa5504dc2e989ae235bd5733 /t | |
parent | real_path(): properly handle nonexistent top-level paths (diff) | |
download | tgif-379a03ad8194192ab7b2910ec3326a981971fda1.tar.xz |
t0060: verify that real_path() removes extra slashes
Adjusted for Windows by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t0060-path-utils.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 30361f94a4..e40f764d54 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 && |