From daf19a80fa6b7402f8a2efa8f8255b4b5d6b48a9 Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Mon, 14 Oct 2013 10:29:38 +0800 Subject: test: use unambigous leading path (/foo) for MSYS In test cases for relative_path, path with one leading character (such as /a, /x) may be recogonized as "a:/" or "x:/" if there is such DOS drive on MSYS platform. Use an umambigous leading path "/foo" instead. Also change two leading slashes (//) to three leading slashes (///), otherwize it will be recognized as UNC name on MSYS platform. Signed-off-by: Jiang Xin Acked-by: Sebastian Schuberth Signed-off-by: Jonathan Nieder --- t/t0060-path-utils.sh | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 't') diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 3a48de20d8..92976e0402 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -190,33 +190,33 @@ test_expect_success SYMLINKS 'real path works on symlinks' ' test "$sym" = "$(test-path-utils real_path "$dir2/syml")" ' -relative_path /a/b/c/ /a/b/ c/ -relative_path /a/b/c/ /a/b c/ -relative_path /a//b//c/ //a/b// c/ POSIX -relative_path /a/b /a/b ./ -relative_path /a/b/ /a/b ./ -relative_path /a /a/b ../ -relative_path / /a/b/ ../../ -relative_path /a/c /a/b/ ../c -relative_path /a/c /a/b ../c -relative_path /x/y /a/b/ ../../x/y -relative_path /a/b "" /a/b -relative_path /a/b "" /a/b -relative_path a/b/c/ a/b/ c/ -relative_path a/b/c/ a/b c/ -relative_path a/b//c a//b c -relative_path a/b/ a/b/ ./ -relative_path a/b/ a/b ./ -relative_path a a/b ../ -relative_path x/y a/b ../../x/y -relative_path a/c a/b ../c -relative_path a/b "" a/b -relative_path a/b "" a/b -relative_path "" /a/b ./ -relative_path "" "" ./ -relative_path "" "" ./ -relative_path "" "" ./ -relative_path "" "" ./ -relative_path "" /a/b ./ +relative_path /foo/a/b/c/ /foo/a/b/ c/ +relative_path /foo/a/b/c/ /foo/a/b c/ +relative_path /foo/a//b//c/ ///foo/a/b// c/ POSIX +relative_path /foo/a/b /foo/a/b ./ +relative_path /foo/a/b/ /foo/a/b ./ +relative_path /foo/a /foo/a/b ../ +relative_path / /foo/a/b/ ../../../ +relative_path /foo/a/c /foo/a/b/ ../c +relative_path /foo/a/c /foo/a/b ../c +relative_path /foo/x/y /foo/a/b/ ../../x/y +relative_path /foo/a/b "" /foo/a/b +relative_path /foo/a/b "" /foo/a/b +relative_path foo/a/b/c/ foo/a/b/ c/ +relative_path foo/a/b/c/ foo/a/b c/ +relative_path foo/a/b//c foo/a//b c +relative_path foo/a/b/ foo/a/b/ ./ +relative_path foo/a/b/ foo/a/b ./ +relative_path foo/a foo/a/b ../ +relative_path foo/x/y foo/a/b ../../x/y +relative_path foo/a/c foo/a/b ../c +relative_path foo/a/b "" foo/a/b +relative_path foo/a/b "" foo/a/b +relative_path "" /foo/a/b ./ +relative_path "" "" ./ +relative_path "" "" ./ +relative_path "" "" ./ +relative_path "" "" ./ +relative_path "" /foo/a/b ./ test_done -- cgit v1.2.1 From 7fbd422162f2b49bc06a29a063f519450165dc86 Mon Sep 17 00:00:00 2001 From: Jiang Xin Date: Mon, 14 Oct 2013 10:29:39 +0800 Subject: relative_path should honor dos-drive-prefix Tvangeste found that the "relative_path" function could not work properly on Windows if "in" and "prefix" have DOS drive prefix (such as "C:/windows"). ($gmane/234434) E.g., When execute: test-path-utils relative_path "C:/a/b" "D:/x/y", should return "C:/a/b", but returns "../../C:/a/b", which is wrong. So make relative_path honor DOS drive prefix, and add test cases for it in t0060. Reported-by: Tvangeste Helped-by: Johannes Sixt Signed-off-by: Jiang Xin Signed-off-by: Jonathan Nieder --- t/t0060-path-utils.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't') diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 92976e0402..40dfa2df6e 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -210,6 +210,10 @@ relative_path foo/a/b/ foo/a/b ./ relative_path foo/a foo/a/b ../ relative_path foo/x/y foo/a/b ../../x/y relative_path foo/a/c foo/a/b ../c +relative_path foo/a/b /foo/x/y foo/a/b +relative_path /foo/a/b foo/x/y /foo/a/b +relative_path d:/a/b D:/a/c ../b MINGW +relative_path C:/a/b D:/a/c C:/a/b MINGW relative_path foo/a/b "" foo/a/b relative_path foo/a/b "" foo/a/b relative_path "" /foo/a/b ./ -- cgit v1.2.1