Skip to content

Commit 379a03a

Browse files
mhaggergitster
authored andcommitted
t0060: verify that real_path() removes extra slashes
Adjusted for Windows by: Johannes Sixt <[email protected]> Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f4c21e8 commit 379a03a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

t/t0060-path-utils.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ test_expect_success POSIX 'real path works on absolute paths' '
158158
test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")"
159159
'
160160

161+
test_expect_success POSIX 'real path removes extra leading slashes' '
162+
nopath="hopefully-absent-path" &&
163+
test "/" = "$(test-path-utils real_path "///")" &&
164+
test "/$nopath" = "$(test-path-utils real_path "///$nopath")" &&
165+
# Find an existing top-level directory for the remaining tests:
166+
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
167+
test "$d" = "$(test-path-utils real_path "//$d")" &&
168+
test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")"
169+
'
170+
171+
test_expect_success 'real path removes other extra slashes' '
172+
nopath="hopefully-absent-path" &&
173+
# Find an existing top-level directory for the remaining tests:
174+
d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
175+
test "$d" = "$(test-path-utils real_path "$d///")" &&
176+
test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")"
177+
'
178+
161179
test_expect_success SYMLINKS 'real path works on symlinks' '
162180
mkdir first &&
163181
ln -s ../.git first/.git &&

0 commit comments

Comments
 (0)