David Reiss | ae299be | 2008-05-19 23:48:54 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2008 David Reiss |
| 4 | # |
| 5 | |
| 6 | test_description='Test various path utilities' |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 10 | norm_path() { |
Sebastian Schuberth | 7ffd18f | 2013-10-10 22:49:43 +0200 | [diff] [blame] | 11 | expected=$(test-path-utils print_path "$2") |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 12 | test_expect_success $3 "normalize path: $1 => $2" \ |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 13 | "test \"\$(test-path-utils normalize_path_copy '$1')\" = '$expected'" |
David Reiss | ae299be | 2008-05-19 23:48:54 -0700 | [diff] [blame] | 14 | } |
| 15 | |
Jiang Xin | 203439b | 2013-06-25 23:53:42 +0800 | [diff] [blame] | 16 | relative_path() { |
Sebastian Schuberth | 7ffd18f | 2013-10-10 22:49:43 +0200 | [diff] [blame] | 17 | expected=$(test-path-utils print_path "$3") |
Jiang Xin | 203439b | 2013-06-25 23:53:42 +0800 | [diff] [blame] | 18 | test_expect_success $4 "relative path: $1 $2 => $3" \ |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 19 | "test \"\$(test-path-utils relative_path '$1' '$2')\" = '$expected'" |
Jiang Xin | 203439b | 2013-06-25 23:53:42 +0800 | [diff] [blame] | 20 | } |
| 21 | |
Stefan Beller | 63e95be | 2016-04-15 17:50:12 -0700 | [diff] [blame] | 22 | test_submodule_relative_url() { |
| 23 | test_expect_success "test_submodule_relative_url: $1 $2 $3 => $4" " |
| 24 | actual=\$(git submodule--helper resolve-relative-url-test '$1' '$2' '$3') && |
| 25 | test \"\$actual\" = '$4' |
| 26 | " |
| 27 | } |
| 28 | |
Nguyễn Thái Ngọc Duy | 557bd83 | 2014-11-30 15:24:31 +0700 | [diff] [blame] | 29 | test_git_path() { |
| 30 | test_expect_success "git-path $1 $2 => $3" " |
| 31 | $1 git rev-parse --git-path $2 >actual && |
| 32 | echo $3 >expect && |
| 33 | test_cmp expect actual |
| 34 | " |
| 35 | } |
| 36 | |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 37 | # On Windows, we are using MSYS's bash, which mangles the paths. |
| 38 | # Absolute paths are anchored at the MSYS installation directory, |
| 39 | # which means that the path / accounts for this many characters: |
| 40 | rootoff=$(test-path-utils normalize_path_copy / | wc -c) |
| 41 | # Account for the trailing LF: |
Jeff King | 28baf82 | 2009-03-23 02:22:29 -0400 | [diff] [blame] | 42 | if test $rootoff = 2; then |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 43 | rootoff= # we are on Unix |
| 44 | else |
| 45 | rootoff=$(($rootoff-1)) |
Johannes Schindelin | fc56c7b | 2016-01-27 17:19:40 +0100 | [diff] [blame] | 46 | # In MSYS2, the root directory "/" is translated into a Windows |
| 47 | # directory *with* trailing slash. Let's test for that and adjust |
| 48 | # our expected longest ancestor length accordingly. |
| 49 | case "$(test-path-utils print_path /)" in |
| 50 | */) rootslash=1;; |
| 51 | *) rootslash=0;; |
| 52 | esac |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 53 | fi |
| 54 | |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 55 | ancestor() { |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 56 | # We do some math with the expected ancestor length. |
| 57 | expected=$3 |
| 58 | if test -n "$rootoff" && test "x$expected" != x-1; then |
Johannes Schindelin | fc56c7b | 2016-01-27 17:19:40 +0100 | [diff] [blame] | 59 | expected=$(($expected-$rootslash)) |
| 60 | test $expected -lt 0 || |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 61 | expected=$(($expected+$rootoff)) |
| 62 | fi |
| 63 | test_expect_success "longest ancestor: $1 $2 => $expected" \ |
| 64 | "actual=\$(test-path-utils longest_ancestor_length '$1' '$2') && |
| 65 | test \"\$actual\" = '$expected'" |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 68 | # Some absolute path tests should be skipped on Windows due to path mangling |
| 69 | # on POSIX-style absolute paths |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 70 | case $(uname -s) in |
| 71 | *MINGW*) |
| 72 | ;; |
| 73 | *) |
| 74 | test_set_prereq POSIX |
| 75 | ;; |
| 76 | esac |
| 77 | |
Johannes Schindelin | 7d1aaa6 | 2016-01-12 08:57:57 +0100 | [diff] [blame] | 78 | test_expect_success basename 'test-path-utils basename' |
| 79 | test_expect_success dirname 'test-path-utils dirname' |
| 80 | |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 81 | norm_path "" "" |
| 82 | norm_path . "" |
| 83 | norm_path ./ "" |
| 84 | norm_path ./. "" |
| 85 | norm_path ./.. ++failed++ |
| 86 | norm_path ../. ++failed++ |
| 87 | norm_path ./../.// ++failed++ |
| 88 | norm_path dir/.. "" |
| 89 | norm_path dir/sub/../.. "" |
| 90 | norm_path dir/sub/../../.. ++failed++ |
| 91 | norm_path dir dir |
| 92 | norm_path dir// dir/ |
| 93 | norm_path ./dir dir |
| 94 | norm_path dir/. dir/ |
| 95 | norm_path dir///./ dir/ |
| 96 | norm_path dir//sub/.. dir/ |
| 97 | norm_path dir/sub/../ dir/ |
| 98 | norm_path dir/sub/../. dir/ |
| 99 | norm_path dir/s1/../s2/ dir/s2/ |
| 100 | norm_path d1/s1///s2/..//../s3/ d1/s3/ |
| 101 | norm_path d1/s1//../s2/../../d2 d2 |
| 102 | norm_path d1/.../d2 d1/.../d2 |
| 103 | norm_path d1/..././../d2 d1/d2 |
| 104 | |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 105 | norm_path / / |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 106 | norm_path // / POSIX |
| 107 | norm_path /// / POSIX |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 108 | norm_path /. / |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 109 | norm_path /./ / POSIX |
| 110 | norm_path /./.. ++failed++ POSIX |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 111 | norm_path /../. ++failed++ |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 112 | norm_path /./../.// ++failed++ POSIX |
| 113 | norm_path /dir/.. / POSIX |
| 114 | norm_path /dir/sub/../.. / POSIX |
| 115 | norm_path /dir/sub/../../.. ++failed++ POSIX |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 116 | norm_path /dir /dir |
| 117 | norm_path /dir// /dir/ |
| 118 | norm_path /./dir /dir |
| 119 | norm_path /dir/. /dir/ |
| 120 | norm_path /dir///./ /dir/ |
| 121 | norm_path /dir//sub/.. /dir/ |
| 122 | norm_path /dir/sub/../ /dir/ |
Johannes Sixt | 2718e85 | 2009-03-11 22:15:10 +0100 | [diff] [blame] | 123 | norm_path //dir/sub/../. /dir/ POSIX |
Jiang Xin | abd4284 | 2013-06-25 23:53:57 +0800 | [diff] [blame] | 124 | norm_path /dir/s1/../s2/ /dir/s2/ |
| 125 | norm_path /d1/s1///s2/..//../s3/ /d1/s3/ |
| 126 | norm_path /d1/s1//../s2/../../d2 /d2 |
| 127 | norm_path /d1/.../d2 /d1/.../d2 |
| 128 | norm_path /d1/..././../d2 /d1/d2 |
David Reiss | ae299be | 2008-05-19 23:48:54 -0700 | [diff] [blame] | 129 | |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 130 | ancestor / / -1 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 131 | ancestor /foo / 0 |
| 132 | ancestor /foo /fo -1 |
| 133 | ancestor /foo /foo -1 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 134 | ancestor /foo /bar -1 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 135 | ancestor /foo /foo/bar -1 |
Michael Haggerty | 9e2326c | 2012-10-28 17:16:25 +0100 | [diff] [blame] | 136 | ancestor /foo /foo:/bar -1 |
| 137 | ancestor /foo /:/foo:/bar 0 |
| 138 | ancestor /foo /foo:/:/bar 0 |
| 139 | ancestor /foo /:/bar:/foo 0 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 140 | ancestor /foo/bar / 0 |
| 141 | ancestor /foo/bar /fo -1 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 142 | ancestor /foo/bar /foo 4 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 143 | ancestor /foo/bar /foo/ba -1 |
| 144 | ancestor /foo/bar /:/fo 0 |
| 145 | ancestor /foo/bar /foo:/foo/ba 4 |
| 146 | ancestor /foo/bar /bar -1 |
Michael Haggerty | 9e2326c | 2012-10-28 17:16:25 +0100 | [diff] [blame] | 147 | ancestor /foo/bar /fo -1 |
| 148 | ancestor /foo/bar /foo:/bar 4 |
| 149 | ancestor /foo/bar /:/foo:/bar 4 |
| 150 | ancestor /foo/bar /foo:/:/bar 4 |
| 151 | ancestor /foo/bar /:/bar:/fo 0 |
| 152 | ancestor /foo/bar /:/bar 0 |
| 153 | ancestor /foo/bar /foo 4 |
| 154 | ancestor /foo/bar /foo:/bar 4 |
| 155 | ancestor /foo/bar /bar -1 |
David Reiss | 0454dd9 | 2008-05-19 23:49:26 -0700 | [diff] [blame] | 156 | |
Johannes Schindelin | 4fcc86b | 2009-02-19 20:10:49 +0100 | [diff] [blame] | 157 | test_expect_success 'strip_path_suffix' ' |
| 158 | test c:/msysgit = $(test-path-utils strip_path_suffix \ |
| 159 | c:/msysgit/libexec//git-core libexec/git-core) |
| 160 | ' |
Michael Haggerty | 8da650b | 2012-09-07 00:40:57 +0200 | [diff] [blame] | 161 | |
Michael Haggerty | a0601dc | 2012-09-07 00:40:59 +0200 | [diff] [blame] | 162 | test_expect_success 'absolute path rejects the empty string' ' |
Michael Haggerty | 17264bc | 2012-09-07 00:40:58 +0200 | [diff] [blame] | 163 | test_must_fail test-path-utils absolute_path "" |
| 164 | ' |
| 165 | |
Michael Haggerty | 3efe5d1 | 2012-09-07 00:41:01 +0200 | [diff] [blame] | 166 | test_expect_success 'real path rejects the empty string' ' |
Michael Haggerty | a5c4521 | 2012-09-07 00:41:00 +0200 | [diff] [blame] | 167 | test_must_fail test-path-utils real_path "" |
| 168 | ' |
| 169 | |
Johannes Sixt | bacca78 | 2012-09-09 17:42:20 +0200 | [diff] [blame] | 170 | test_expect_success POSIX 'real path works on absolute paths 1' ' |
Michael Haggerty | 7bcf48d | 2012-09-07 00:41:02 +0200 | [diff] [blame] | 171 | nopath="hopefully-absent-path" && |
| 172 | test "/" = "$(test-path-utils real_path "/")" && |
Johannes Sixt | bacca78 | 2012-09-09 17:42:20 +0200 | [diff] [blame] | 173 | test "/$nopath" = "$(test-path-utils real_path "/$nopath")" |
| 174 | ' |
| 175 | |
| 176 | test_expect_success 'real path works on absolute paths 2' ' |
| 177 | nopath="hopefully-absent-path" && |
Michael Haggerty | 7bcf48d | 2012-09-07 00:41:02 +0200 | [diff] [blame] | 178 | # Find an existing top-level directory for the remaining tests: |
| 179 | d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && |
| 180 | test "$d" = "$(test-path-utils real_path "$d")" && |
| 181 | test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")" |
| 182 | ' |
| 183 | |
Michael Haggerty | 379a03a | 2012-09-07 00:41:04 +0200 | [diff] [blame] | 184 | test_expect_success POSIX 'real path removes extra leading slashes' ' |
| 185 | nopath="hopefully-absent-path" && |
| 186 | test "/" = "$(test-path-utils real_path "///")" && |
| 187 | test "/$nopath" = "$(test-path-utils real_path "///$nopath")" && |
| 188 | # Find an existing top-level directory for the remaining tests: |
| 189 | d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && |
| 190 | test "$d" = "$(test-path-utils real_path "//$d")" && |
| 191 | test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")" |
| 192 | ' |
| 193 | |
| 194 | test_expect_success 'real path removes other extra slashes' ' |
| 195 | nopath="hopefully-absent-path" && |
| 196 | # Find an existing top-level directory for the remaining tests: |
| 197 | d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") && |
| 198 | test "$d" = "$(test-path-utils real_path "$d///")" && |
| 199 | test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")" |
| 200 | ' |
| 201 | |
Michael Haggerty | 7bcf48d | 2012-09-07 00:41:02 +0200 | [diff] [blame] | 202 | test_expect_success SYMLINKS 'real path works on symlinks' ' |
Michael Haggerty | 8da650b | 2012-09-07 00:40:57 +0200 | [diff] [blame] | 203 | mkdir first && |
| 204 | ln -s ../.git first/.git && |
| 205 | mkdir second && |
| 206 | ln -s ../first second/other && |
| 207 | mkdir third && |
| 208 | dir="$(cd .git; pwd -P)" && |
| 209 | dir2=third/../second/other/.git && |
| 210 | test "$dir" = "$(test-path-utils real_path $dir2)" && |
| 211 | file="$dir"/index && |
| 212 | test "$file" = "$(test-path-utils real_path $dir2/index)" && |
| 213 | basename=blub && |
| 214 | test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" && |
| 215 | ln -s ../first/file .git/syml && |
| 216 | sym="$(cd first; pwd -P)"/file && |
| 217 | test "$sym" = "$(test-path-utils real_path "$dir2/syml")" |
| 218 | ' |
| 219 | |
Martin Erik Werner | 655ee9e | 2014-02-04 15:25:20 +0100 | [diff] [blame] | 220 | test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' ' |
Martin Erik Werner | 74af95d | 2014-02-04 15:25:16 +0100 | [diff] [blame] | 221 | ln -s target symlink && |
| 222 | test "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink" |
| 223 | ' |
| 224 | |
Martin Erik Werner | e5aa1fc | 2014-02-04 15:25:17 +0100 | [diff] [blame] | 225 | test_expect_success 'prefix_path works with only absolute path to work tree' ' |
| 226 | echo "" >expected && |
| 227 | test-path-utils prefix_path prefix "$(pwd)" >actual && |
| 228 | test_cmp expected actual |
| 229 | ' |
| 230 | |
Martin Erik Werner | e131daa | 2014-02-04 15:25:18 +0100 | [diff] [blame] | 231 | test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' ' |
| 232 | test_must_fail test-path-utils prefix_path prefix "$(pwd)a" |
| 233 | ' |
| 234 | |
| 235 | test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' ' |
| 236 | git init repo && |
| 237 | ln -s repo repolink && |
| 238 | test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")" |
| 239 | ' |
| 240 | |
Jiang Xin | daf19a8 | 2013-10-14 10:29:38 +0800 | [diff] [blame] | 241 | relative_path /foo/a/b/c/ /foo/a/b/ c/ |
| 242 | relative_path /foo/a/b/c/ /foo/a/b c/ |
| 243 | relative_path /foo/a//b//c/ ///foo/a/b// c/ POSIX |
| 244 | relative_path /foo/a/b /foo/a/b ./ |
| 245 | relative_path /foo/a/b/ /foo/a/b ./ |
| 246 | relative_path /foo/a /foo/a/b ../ |
| 247 | relative_path / /foo/a/b/ ../../../ |
| 248 | relative_path /foo/a/c /foo/a/b/ ../c |
| 249 | relative_path /foo/a/c /foo/a/b ../c |
| 250 | relative_path /foo/x/y /foo/a/b/ ../../x/y |
| 251 | relative_path /foo/a/b "<empty>" /foo/a/b |
| 252 | relative_path /foo/a/b "<null>" /foo/a/b |
| 253 | relative_path foo/a/b/c/ foo/a/b/ c/ |
| 254 | relative_path foo/a/b/c/ foo/a/b c/ |
| 255 | relative_path foo/a/b//c foo/a//b c |
| 256 | relative_path foo/a/b/ foo/a/b/ ./ |
| 257 | relative_path foo/a/b/ foo/a/b ./ |
| 258 | relative_path foo/a foo/a/b ../ |
| 259 | relative_path foo/x/y foo/a/b ../../x/y |
| 260 | relative_path foo/a/c foo/a/b ../c |
Jiang Xin | 7fbd422 | 2013-10-14 10:29:39 +0800 | [diff] [blame] | 261 | relative_path foo/a/b /foo/x/y foo/a/b |
| 262 | relative_path /foo/a/b foo/x/y /foo/a/b |
| 263 | relative_path d:/a/b D:/a/c ../b MINGW |
| 264 | relative_path C:/a/b D:/a/c C:/a/b MINGW |
Jiang Xin | daf19a8 | 2013-10-14 10:29:38 +0800 | [diff] [blame] | 265 | relative_path foo/a/b "<empty>" foo/a/b |
| 266 | relative_path foo/a/b "<null>" foo/a/b |
| 267 | relative_path "<empty>" /foo/a/b ./ |
| 268 | relative_path "<empty>" "<empty>" ./ |
| 269 | relative_path "<empty>" "<null>" ./ |
| 270 | relative_path "<null>" "<empty>" ./ |
| 271 | relative_path "<null>" "<null>" ./ |
| 272 | relative_path "<null>" /foo/a/b ./ |
Jiang Xin | 203439b | 2013-06-25 23:53:42 +0800 | [diff] [blame] | 273 | |
Nguyễn Thái Ngọc Duy | 557bd83 | 2014-11-30 15:24:31 +0700 | [diff] [blame] | 274 | test_git_path A=B info/grafts .git/info/grafts |
| 275 | test_git_path GIT_GRAFT_FILE=foo info/grafts foo |
| 276 | test_git_path GIT_GRAFT_FILE=foo info/////grafts foo |
| 277 | test_git_path GIT_INDEX_FILE=foo index foo |
| 278 | test_git_path GIT_INDEX_FILE=foo index/foo .git/index/foo |
| 279 | test_git_path GIT_INDEX_FILE=foo index2 .git/index2 |
| 280 | test_expect_success 'setup fake objects directory foo' 'mkdir foo' |
| 281 | test_git_path GIT_OBJECT_DIRECTORY=foo objects foo |
| 282 | test_git_path GIT_OBJECT_DIRECTORY=foo objects/foo foo/foo |
| 283 | test_git_path GIT_OBJECT_DIRECTORY=foo objects2 .git/objects2 |
Nguyễn Thái Ngọc Duy | c7b3a3d | 2014-11-30 15:24:36 +0700 | [diff] [blame] | 284 | test_expect_success 'setup common repository' 'git --git-dir=bar init' |
| 285 | test_git_path GIT_COMMON_DIR=bar index .git/index |
| 286 | test_git_path GIT_COMMON_DIR=bar HEAD .git/HEAD |
| 287 | test_git_path GIT_COMMON_DIR=bar logs/HEAD .git/logs/HEAD |
David Turner | ce414b3 | 2015-08-31 22:13:11 -0400 | [diff] [blame] | 288 | test_git_path GIT_COMMON_DIR=bar logs/refs/bisect/foo .git/logs/refs/bisect/foo |
| 289 | test_git_path GIT_COMMON_DIR=bar logs/refs/bisec/foo bar/logs/refs/bisec/foo |
| 290 | test_git_path GIT_COMMON_DIR=bar logs/refs/bisec bar/logs/refs/bisec |
| 291 | test_git_path GIT_COMMON_DIR=bar logs/refs/bisectfoo bar/logs/refs/bisectfoo |
Nguyễn Thái Ngọc Duy | c7b3a3d | 2014-11-30 15:24:36 +0700 | [diff] [blame] | 292 | test_git_path GIT_COMMON_DIR=bar objects bar/objects |
| 293 | test_git_path GIT_COMMON_DIR=bar objects/bar bar/objects/bar |
| 294 | test_git_path GIT_COMMON_DIR=bar info/exclude bar/info/exclude |
| 295 | test_git_path GIT_COMMON_DIR=bar info/grafts bar/info/grafts |
Nguyễn Thái Ngọc Duy | 6cfbdcb | 2014-11-30 15:24:55 +0700 | [diff] [blame] | 296 | test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-checkout |
David Turner | 4e09cf2 | 2015-08-31 22:13:10 -0400 | [diff] [blame] | 297 | test_git_path GIT_COMMON_DIR=bar info//sparse-checkout .git/info//sparse-checkout |
Nguyễn Thái Ngọc Duy | c7b3a3d | 2014-11-30 15:24:36 +0700 | [diff] [blame] | 298 | test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar |
| 299 | test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar |
| 300 | test_git_path GIT_COMMON_DIR=bar logs/refs/heads/master bar/logs/refs/heads/master |
| 301 | test_git_path GIT_COMMON_DIR=bar refs/heads/master bar/refs/heads/master |
David Turner | ce414b3 | 2015-08-31 22:13:11 -0400 | [diff] [blame] | 302 | test_git_path GIT_COMMON_DIR=bar refs/bisect/foo .git/refs/bisect/foo |
Nguyễn Thái Ngọc Duy | c7b3a3d | 2014-11-30 15:24:36 +0700 | [diff] [blame] | 303 | test_git_path GIT_COMMON_DIR=bar hooks/me bar/hooks/me |
| 304 | test_git_path GIT_COMMON_DIR=bar config bar/config |
| 305 | test_git_path GIT_COMMON_DIR=bar packed-refs bar/packed-refs |
| 306 | test_git_path GIT_COMMON_DIR=bar shallow bar/shallow |
Nguyễn Thái Ngọc Duy | 557bd83 | 2014-11-30 15:24:31 +0700 | [diff] [blame] | 307 | |
Johannes Sixt | 77b63ac | 2016-10-18 22:06:07 +0200 | [diff] [blame] | 308 | # In the tests below, $(pwd) must be used because it is a native path on |
| 309 | # Windows and avoids MSYS's path mangling (which simplifies "foo/../bar" and |
| 310 | # strips the dot from trailing "/."). |
Stefan Beller | 63e95be | 2016-04-15 17:50:12 -0700 | [diff] [blame] | 311 | |
| 312 | test_submodule_relative_url "../" "../foo" "../submodule" "../../submodule" |
| 313 | test_submodule_relative_url "../" "../foo/bar" "../submodule" "../../foo/submodule" |
| 314 | test_submodule_relative_url "../" "../foo/submodule" "../submodule" "../../foo/submodule" |
| 315 | test_submodule_relative_url "../" "./foo" "../submodule" "../submodule" |
| 316 | test_submodule_relative_url "../" "./foo/bar" "../submodule" "../foo/submodule" |
| 317 | test_submodule_relative_url "../../../" "../foo/bar" "../sub/a/b/c" "../../../../foo/sub/a/b/c" |
Johannes Sixt | 77b63ac | 2016-10-18 22:06:07 +0200 | [diff] [blame] | 318 | test_submodule_relative_url "../" "$(pwd)/addtest" "../repo" "$(pwd)/repo" |
Stefan Beller | 63e95be | 2016-04-15 17:50:12 -0700 | [diff] [blame] | 319 | test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule" |
| 320 | test_submodule_relative_url "../" "foo" "../submodule" "../submodule" |
| 321 | |
| 322 | test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c" |
Stefan Beller | 3389e78 | 2016-10-10 10:56:11 -0700 | [diff] [blame] | 323 | test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c" |
Stefan Beller | 0878850 | 2016-10-10 10:56:10 -0700 | [diff] [blame] | 324 | test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c" |
Stefan Beller | 63e95be | 2016-04-15 17:50:12 -0700 | [diff] [blame] | 325 | test_submodule_relative_url "(null)" "../foo/bar" "../submodule" "../foo/submodule" |
| 326 | test_submodule_relative_url "(null)" "../foo/submodule" "../submodule" "../foo/submodule" |
| 327 | test_submodule_relative_url "(null)" "../foo" "../submodule" "../submodule" |
| 328 | test_submodule_relative_url "(null)" "./foo/bar" "../submodule" "foo/submodule" |
| 329 | test_submodule_relative_url "(null)" "./foo" "../submodule" "submodule" |
| 330 | test_submodule_relative_url "(null)" "//somewhere else/repo" "../subrepo" "//somewhere else/subrepo" |
Johannes Sixt | 77b63ac | 2016-10-18 22:06:07 +0200 | [diff] [blame] | 331 | test_submodule_relative_url "(null)" "$(pwd)/subsuper_update_r" "../subsubsuper_update_r" "$(pwd)/subsubsuper_update_r" |
| 332 | test_submodule_relative_url "(null)" "$(pwd)/super_update_r2" "../subsuper_update_r" "$(pwd)/subsuper_update_r" |
| 333 | test_submodule_relative_url "(null)" "$(pwd)/." "../." "$(pwd)/." |
| 334 | test_submodule_relative_url "(null)" "$(pwd)" "./." "$(pwd)/." |
| 335 | test_submodule_relative_url "(null)" "$(pwd)/addtest" "../repo" "$(pwd)/repo" |
| 336 | test_submodule_relative_url "(null)" "$(pwd)" "./å äö" "$(pwd)/å äö" |
| 337 | test_submodule_relative_url "(null)" "$(pwd)/." "../submodule" "$(pwd)/submodule" |
| 338 | test_submodule_relative_url "(null)" "$(pwd)/submodule" "../submodule" "$(pwd)/submodule" |
| 339 | test_submodule_relative_url "(null)" "$(pwd)/home2/../remote" "../bundle1" "$(pwd)/home2/../bundle1" |
| 340 | test_submodule_relative_url "(null)" "$(pwd)/submodule_update_repo" "./." "$(pwd)/submodule_update_repo/." |
Stefan Beller | 63e95be | 2016-04-15 17:50:12 -0700 | [diff] [blame] | 341 | test_submodule_relative_url "(null)" "file:///tmp/repo" "../subrepo" "file:///tmp/subrepo" |
| 342 | test_submodule_relative_url "(null)" "foo/bar" "../submodule" "foo/submodule" |
| 343 | test_submodule_relative_url "(null)" "foo" "../submodule" "submodule" |
| 344 | test_submodule_relative_url "(null)" "helper:://hostname/repo" "../subrepo" "helper:://hostname/subrepo" |
| 345 | test_submodule_relative_url "(null)" "ssh://hostname/repo" "../subrepo" "ssh://hostname/subrepo" |
| 346 | test_submodule_relative_url "(null)" "ssh://hostname:22/repo" "../subrepo" "ssh://hostname:22/subrepo" |
| 347 | test_submodule_relative_url "(null)" "user@host:path/to/repo" "../subrepo" "user@host:path/to/subrepo" |
| 348 | test_submodule_relative_url "(null)" "user@host:repo" "../subrepo" "user@host:subrepo" |
| 349 | |
David Reiss | ae299be | 2008-05-19 23:48:54 -0700 | [diff] [blame] | 350 | test_done |