]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0060-path-utils.sh
Merge branch 'jk/clone-allow-bare-and-o-together'
[thirdparty/git.git] / t / t0060-path-utils.sh
CommitLineData
ae299be0
DR
1#!/bin/sh
2#
3# Copyright (c) 2008 David Reiss
4#
5
6test_description='Test various path utilities'
7
e287a5b0 8TEST_PASSES_SANITIZE_LEAK=true
ae299be0
DR
9. ./test-lib.sh
10
2718e852 11norm_path() {
b8d5cf4f 12 expected=$(test-tool path-utils print_path "$2")
2718e852 13 test_expect_success $3 "normalize path: $1 => $2" \
b8d5cf4f 14 "test \"\$(test-tool path-utils normalize_path_copy '$1')\" = '$expected'"
ae299be0
DR
15}
16
203439b2 17relative_path() {
b8d5cf4f 18 expected=$(test-tool path-utils print_path "$3")
203439b2 19 test_expect_success $4 "relative path: $1 $2 => $3" \
b8d5cf4f 20 "test \"\$(test-tool path-utils relative_path '$1' '$2')\" = '$expected'"
203439b2
JX
21}
22
63e95beb
SB
23test_submodule_relative_url() {
24 test_expect_success "test_submodule_relative_url: $1 $2 $3 => $4" "
96a28a9b 25 actual=\$(test-tool submodule resolve-relative-url '$1' '$2' '$3') &&
63e95beb
SB
26 test \"\$actual\" = '$4'
27 "
28}
29
557bd833
NTND
30test_git_path() {
31 test_expect_success "git-path $1 $2 => $3" "
32 $1 git rev-parse --git-path $2 >actual &&
33 echo $3 >expect &&
34 test_cmp expect actual
35 "
36}
37
2718e852
JS
38# On Windows, we are using MSYS's bash, which mangles the paths.
39# Absolute paths are anchored at the MSYS installation directory,
40# which means that the path / accounts for this many characters:
b8d5cf4f 41rootoff=$(test-tool path-utils normalize_path_copy / | wc -c)
2718e852 42# Account for the trailing LF:
28baf82e 43if test $rootoff = 2; then
2718e852
JS
44 rootoff= # we are on Unix
45else
46 rootoff=$(($rootoff-1))
fc56c7b3
JS
47 # In MSYS2, the root directory "/" is translated into a Windows
48 # directory *with* trailing slash. Let's test for that and adjust
49 # our expected longest ancestor length accordingly.
b8d5cf4f 50 case "$(test-tool path-utils print_path /)" in
fc56c7b3
JS
51 */) rootslash=1;;
52 *) rootslash=0;;
53 esac
2718e852
JS
54fi
55
0454dd93 56ancestor() {
2718e852
JS
57 # We do some math with the expected ancestor length.
58 expected=$3
fdcad5a5
JS
59 case "$rootoff,$expected,$2" in
60 *,*,//*) ;; # leave UNC paths alone
61 [0-9]*,[0-9]*,/*)
62 # On Windows, expect MSYS2 pseudo root translation for
63 # Unix-style absolute paths
64 expected=$(($expected-$rootslash+$rootoff))
65 ;;
66 esac
67 test_expect_success $4 "longest ancestor: $1 $2 => $expected" \
b8d5cf4f 68 "actual=\$(test-tool path-utils longest_ancestor_length '$1' '$2') &&
2718e852 69 test \"\$actual\" = '$expected'"
0454dd93
DR
70}
71
abd4284b
JX
72# Some absolute path tests should be skipped on Windows due to path mangling
73# on POSIX-style absolute paths
2718e852
JS
74case $(uname -s) in
75*MINGW*)
76 ;;
496f2569
TB
77*CYGWIN*)
78 ;;
2718e852
JS
79*)
80 test_set_prereq POSIX
81 ;;
82esac
83
b8d5cf4f
NTND
84test_expect_success basename 'test-tool path-utils basename'
85test_expect_success dirname 'test-tool path-utils dirname'
7d1aaa68 86
2718e852
JS
87norm_path "" ""
88norm_path . ""
89norm_path ./ ""
90norm_path ./. ""
91norm_path ./.. ++failed++
92norm_path ../. ++failed++
93norm_path ./../.// ++failed++
94norm_path dir/.. ""
95norm_path dir/sub/../.. ""
96norm_path dir/sub/../../.. ++failed++
97norm_path dir dir
98norm_path dir// dir/
99norm_path ./dir dir
100norm_path dir/. dir/
101norm_path dir///./ dir/
102norm_path dir//sub/.. dir/
103norm_path dir/sub/../ dir/
104norm_path dir/sub/../. dir/
105norm_path dir/s1/../s2/ dir/s2/
106norm_path d1/s1///s2/..//../s3/ d1/s3/
107norm_path d1/s1//../s2/../../d2 d2
108norm_path d1/.../d2 d1/.../d2
109norm_path d1/..././../d2 d1/d2
110
abd4284b 111norm_path / /
2718e852
JS
112norm_path // / POSIX
113norm_path /// / POSIX
abd4284b 114norm_path /. /
2718e852
JS
115norm_path /./ / POSIX
116norm_path /./.. ++failed++ POSIX
abd4284b 117norm_path /../. ++failed++
2718e852
JS
118norm_path /./../.// ++failed++ POSIX
119norm_path /dir/.. / POSIX
120norm_path /dir/sub/../.. / POSIX
121norm_path /dir/sub/../../.. ++failed++ POSIX
abd4284b
JX
122norm_path /dir /dir
123norm_path /dir// /dir/
124norm_path /./dir /dir
125norm_path /dir/. /dir/
126norm_path /dir///./ /dir/
127norm_path /dir//sub/.. /dir/
128norm_path /dir/sub/../ /dir/
2718e852 129norm_path //dir/sub/../. /dir/ POSIX
abd4284b
JX
130norm_path /dir/s1/../s2/ /dir/s2/
131norm_path /d1/s1///s2/..//../s3/ /d1/s3/
132norm_path /d1/s1//../s2/../../d2 /d2
133norm_path /d1/.../d2 /d1/.../d2
134norm_path /d1/..././../d2 /d1/d2
ae299be0 135
0454dd93 136ancestor / / -1
0454dd93
DR
137ancestor /foo / 0
138ancestor /foo /fo -1
139ancestor /foo /foo -1
0454dd93 140ancestor /foo /bar -1
0454dd93 141ancestor /foo /foo/bar -1
9e2326c7
MH
142ancestor /foo /foo:/bar -1
143ancestor /foo /:/foo:/bar 0
144ancestor /foo /foo:/:/bar 0
145ancestor /foo /:/bar:/foo 0
0454dd93
DR
146ancestor /foo/bar / 0
147ancestor /foo/bar /fo -1
0454dd93 148ancestor /foo/bar /foo 4
0454dd93
DR
149ancestor /foo/bar /foo/ba -1
150ancestor /foo/bar /:/fo 0
151ancestor /foo/bar /foo:/foo/ba 4
152ancestor /foo/bar /bar -1
9e2326c7
MH
153ancestor /foo/bar /fo -1
154ancestor /foo/bar /foo:/bar 4
155ancestor /foo/bar /:/foo:/bar 4
156ancestor /foo/bar /foo:/:/bar 4
157ancestor /foo/bar /:/bar:/fo 0
158ancestor /foo/bar /:/bar 0
159ancestor /foo/bar /foo 4
160ancestor /foo/bar /foo:/bar 4
161ancestor /foo/bar /bar -1
0454dd93 162
fdcad5a5
JS
163# Windows-specific: DOS drives, network shares
164ancestor C:/Users/me C:/ 2 MINGW
165ancestor D:/Users/me C:/ -1 MINGW
166ancestor //server/share/my-directory //server/share/ 14 MINGW
167
4fcc86b0 168test_expect_success 'strip_path_suffix' '
b8d5cf4f 169 test c:/msysgit = $(test-tool path-utils strip_path_suffix \
4fcc86b0
JS
170 c:/msysgit/libexec//git-core libexec/git-core)
171'
8da650b4 172
a0601dc1 173test_expect_success 'absolute path rejects the empty string' '
b8d5cf4f 174 test_must_fail test-tool path-utils absolute_path ""
17264bcc
MH
175'
176
f82a97eb
JS
177test_expect_success MINGW '<drive-letter>:\\abc is an absolute path' '
178 for letter in : \" C Z 1 ä
179 do
180 path=$letter:\\abc &&
14af7ed5 181 absolute="$(test-tool path-utils absolute_path "$path")" &&
f82a97eb
JS
182 test "$path" = "$absolute" || return 1
183 done
184'
185
3efe5d1d 186test_expect_success 'real path rejects the empty string' '
b8d5cf4f 187 test_must_fail test-tool path-utils real_path ""
a5c45218
MH
188'
189
bacca785 190test_expect_success POSIX 'real path works on absolute paths 1' '
7bcf48da 191 nopath="hopefully-absent-path" &&
b8d5cf4f
NTND
192 test "/" = "$(test-tool path-utils real_path "/")" &&
193 test "/$nopath" = "$(test-tool path-utils real_path "/$nopath")"
bacca785
JS
194'
195
196test_expect_success 'real path works on absolute paths 2' '
197 nopath="hopefully-absent-path" &&
7bcf48da
MH
198 # Find an existing top-level directory for the remaining tests:
199 d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
b8d5cf4f
NTND
200 test "$d" = "$(test-tool path-utils real_path "$d")" &&
201 test "$d/$nopath" = "$(test-tool path-utils real_path "$d/$nopath")"
7bcf48da
MH
202'
203
379a03ad
MH
204test_expect_success POSIX 'real path removes extra leading slashes' '
205 nopath="hopefully-absent-path" &&
b8d5cf4f
NTND
206 test "/" = "$(test-tool path-utils real_path "///")" &&
207 test "/$nopath" = "$(test-tool path-utils real_path "///$nopath")" &&
379a03ad
MH
208 # Find an existing top-level directory for the remaining tests:
209 d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
b8d5cf4f
NTND
210 test "$d" = "$(test-tool path-utils real_path "//$d")" &&
211 test "$d/$nopath" = "$(test-tool path-utils real_path "//$d/$nopath")"
379a03ad
MH
212'
213
214test_expect_success 'real path removes other extra slashes' '
215 nopath="hopefully-absent-path" &&
216 # Find an existing top-level directory for the remaining tests:
217 d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
b8d5cf4f
NTND
218 test "$d" = "$(test-tool path-utils real_path "$d///")" &&
219 test "$d/$nopath" = "$(test-tool path-utils real_path "$d///$nopath")"
379a03ad
MH
220'
221
7bcf48da 222test_expect_success SYMLINKS 'real path works on symlinks' '
8da650b4
MH
223 mkdir first &&
224 ln -s ../.git first/.git &&
225 mkdir second &&
226 ln -s ../first second/other &&
227 mkdir third &&
c576868e 228 dir="$(cd .git && pwd -P)" &&
8da650b4 229 dir2=third/../second/other/.git &&
b8d5cf4f 230 test "$dir" = "$(test-tool path-utils real_path $dir2)" &&
8da650b4 231 file="$dir"/index &&
b8d5cf4f 232 test "$file" = "$(test-tool path-utils real_path $dir2/index)" &&
8da650b4 233 basename=blub &&
b8d5cf4f 234 test "$dir/$basename" = "$(cd .git && test-tool path-utils real_path "$basename")" &&
8da650b4 235 ln -s ../first/file .git/syml &&
c576868e 236 sym="$(cd first && pwd -P)"/file &&
b8d5cf4f 237 test "$sym" = "$(test-tool path-utils real_path "$dir2/syml")"
8da650b4
MH
238'
239
655ee9ea 240test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' '
74af95d6 241 ln -s target symlink &&
b8d5cf4f 242 test "$(test-tool path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
74af95d6
MEW
243'
244
e5aa1fc4
MEW
245test_expect_success 'prefix_path works with only absolute path to work tree' '
246 echo "" >expected &&
b8d5cf4f 247 test-tool path-utils prefix_path prefix "$(pwd)" >actual &&
e5aa1fc4
MEW
248 test_cmp expected actual
249'
250
e131daa4 251test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' '
b8d5cf4f 252 test_must_fail test-tool path-utils prefix_path prefix "$(pwd)a"
e131daa4
MEW
253'
254
255test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
256 git init repo &&
257 ln -s repo repolink &&
b8d5cf4f 258 test "a" = "$(cd repo && test-tool path-utils prefix_path prefix "$(pwd)/../repolink/a")"
e131daa4
MEW
259'
260
daf19a80
JX
261relative_path /foo/a/b/c/ /foo/a/b/ c/
262relative_path /foo/a/b/c/ /foo/a/b c/
263relative_path /foo/a//b//c/ ///foo/a/b// c/ POSIX
264relative_path /foo/a/b /foo/a/b ./
265relative_path /foo/a/b/ /foo/a/b ./
266relative_path /foo/a /foo/a/b ../
267relative_path / /foo/a/b/ ../../../
268relative_path /foo/a/c /foo/a/b/ ../c
269relative_path /foo/a/c /foo/a/b ../c
270relative_path /foo/x/y /foo/a/b/ ../../x/y
271relative_path /foo/a/b "<empty>" /foo/a/b
272relative_path /foo/a/b "<null>" /foo/a/b
273relative_path foo/a/b/c/ foo/a/b/ c/
274relative_path foo/a/b/c/ foo/a/b c/
275relative_path foo/a/b//c foo/a//b c
276relative_path foo/a/b/ foo/a/b/ ./
277relative_path foo/a/b/ foo/a/b ./
278relative_path foo/a foo/a/b ../
279relative_path foo/x/y foo/a/b ../../x/y
280relative_path foo/a/c foo/a/b ../c
7fbd4221
JX
281relative_path foo/a/b /foo/x/y foo/a/b
282relative_path /foo/a/b foo/x/y /foo/a/b
283relative_path d:/a/b D:/a/c ../b MINGW
284relative_path C:/a/b D:/a/c C:/a/b MINGW
daf19a80
JX
285relative_path foo/a/b "<empty>" foo/a/b
286relative_path foo/a/b "<null>" foo/a/b
287relative_path "<empty>" /foo/a/b ./
288relative_path "<empty>" "<empty>" ./
289relative_path "<empty>" "<null>" ./
290relative_path "<null>" "<empty>" ./
291relative_path "<null>" "<null>" ./
292relative_path "<null>" /foo/a/b ./
203439b2 293
557bd833
NTND
294test_git_path A=B info/grafts .git/info/grafts
295test_git_path GIT_GRAFT_FILE=foo info/grafts foo
296test_git_path GIT_GRAFT_FILE=foo info/////grafts foo
297test_git_path GIT_INDEX_FILE=foo index foo
298test_git_path GIT_INDEX_FILE=foo index/foo .git/index/foo
299test_git_path GIT_INDEX_FILE=foo index2 .git/index2
300test_expect_success 'setup fake objects directory foo' 'mkdir foo'
301test_git_path GIT_OBJECT_DIRECTORY=foo objects foo
302test_git_path GIT_OBJECT_DIRECTORY=foo objects/foo foo/foo
303test_git_path GIT_OBJECT_DIRECTORY=foo objects2 .git/objects2
c7b3a3d2
NTND
304test_expect_success 'setup common repository' 'git --git-dir=bar init'
305test_git_path GIT_COMMON_DIR=bar index .git/index
76a53d64 306test_git_path GIT_COMMON_DIR=bar index.lock .git/index.lock
c7b3a3d2
NTND
307test_git_path GIT_COMMON_DIR=bar HEAD .git/HEAD
308test_git_path GIT_COMMON_DIR=bar logs/HEAD .git/logs/HEAD
76a53d64 309test_git_path GIT_COMMON_DIR=bar logs/HEAD.lock .git/logs/HEAD.lock
ce414b33 310test_git_path GIT_COMMON_DIR=bar logs/refs/bisect/foo .git/logs/refs/bisect/foo
f45f88b2
SG
311test_git_path GIT_COMMON_DIR=bar logs/refs bar/logs/refs
312test_git_path GIT_COMMON_DIR=bar logs/refs/ bar/logs/refs/
ce414b33
DT
313test_git_path GIT_COMMON_DIR=bar logs/refs/bisec/foo bar/logs/refs/bisec/foo
314test_git_path GIT_COMMON_DIR=bar logs/refs/bisec bar/logs/refs/bisec
315test_git_path GIT_COMMON_DIR=bar logs/refs/bisectfoo bar/logs/refs/bisectfoo
c7b3a3d2
NTND
316test_git_path GIT_COMMON_DIR=bar objects bar/objects
317test_git_path GIT_COMMON_DIR=bar objects/bar bar/objects/bar
318test_git_path GIT_COMMON_DIR=bar info/exclude bar/info/exclude
319test_git_path GIT_COMMON_DIR=bar info/grafts bar/info/grafts
6cfbdcb2 320test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-checkout
4e09cf2a 321test_git_path GIT_COMMON_DIR=bar info//sparse-checkout .git/info//sparse-checkout
c7b3a3d2
NTND
322test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar
323test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar
06d53148
JS
324test_git_path GIT_COMMON_DIR=bar logs/refs/heads/main bar/logs/refs/heads/main
325test_git_path GIT_COMMON_DIR=bar refs/heads/main bar/refs/heads/main
ce414b33 326test_git_path GIT_COMMON_DIR=bar refs/bisect/foo .git/refs/bisect/foo
c7b3a3d2
NTND
327test_git_path GIT_COMMON_DIR=bar hooks/me bar/hooks/me
328test_git_path GIT_COMMON_DIR=bar config bar/config
329test_git_path GIT_COMMON_DIR=bar packed-refs bar/packed-refs
330test_git_path GIT_COMMON_DIR=bar shallow bar/shallow
8aff1a9c
NTND
331test_git_path GIT_COMMON_DIR=bar common bar/common
332test_git_path GIT_COMMON_DIR=bar common/file bar/common/file
557bd833 333
77b63ac3
JS
334# In the tests below, $(pwd) must be used because it is a native path on
335# Windows and avoids MSYS's path mangling (which simplifies "foo/../bar" and
336# strips the dot from trailing "/.").
63e95beb
SB
337
338test_submodule_relative_url "../" "../foo" "../submodule" "../../submodule"
339test_submodule_relative_url "../" "../foo/bar" "../submodule" "../../foo/submodule"
340test_submodule_relative_url "../" "../foo/submodule" "../submodule" "../../foo/submodule"
341test_submodule_relative_url "../" "./foo" "../submodule" "../submodule"
342test_submodule_relative_url "../" "./foo/bar" "../submodule" "../foo/submodule"
343test_submodule_relative_url "../../../" "../foo/bar" "../sub/a/b/c" "../../../../foo/sub/a/b/c"
77b63ac3 344test_submodule_relative_url "../" "$(pwd)/addtest" "../repo" "$(pwd)/repo"
63e95beb
SB
345test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
346test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
347
348test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
3389e78e 349test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c"
08788504 350test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c"
63e95beb
SB
351test_submodule_relative_url "(null)" "../foo/bar" "../submodule" "../foo/submodule"
352test_submodule_relative_url "(null)" "../foo/submodule" "../submodule" "../foo/submodule"
353test_submodule_relative_url "(null)" "../foo" "../submodule" "../submodule"
354test_submodule_relative_url "(null)" "./foo/bar" "../submodule" "foo/submodule"
355test_submodule_relative_url "(null)" "./foo" "../submodule" "submodule"
356test_submodule_relative_url "(null)" "//somewhere else/repo" "../subrepo" "//somewhere else/subrepo"
2711b1ad
ÆAB
357test_submodule_relative_url "(null)" "//somewhere else/repo" "../../subrepo" "//subrepo"
358test_submodule_relative_url "(null)" "//somewhere else/repo" "../../../subrepo" "/subrepo"
359test_submodule_relative_url "(null)" "//somewhere else/repo" "../../../../subrepo" "subrepo"
77b63ac3
JS
360test_submodule_relative_url "(null)" "$(pwd)/subsuper_update_r" "../subsubsuper_update_r" "$(pwd)/subsubsuper_update_r"
361test_submodule_relative_url "(null)" "$(pwd)/super_update_r2" "../subsuper_update_r" "$(pwd)/subsuper_update_r"
362test_submodule_relative_url "(null)" "$(pwd)/." "../." "$(pwd)/."
363test_submodule_relative_url "(null)" "$(pwd)" "./." "$(pwd)/."
364test_submodule_relative_url "(null)" "$(pwd)/addtest" "../repo" "$(pwd)/repo"
365test_submodule_relative_url "(null)" "$(pwd)" "./å äö" "$(pwd)/å äö"
366test_submodule_relative_url "(null)" "$(pwd)/." "../submodule" "$(pwd)/submodule"
367test_submodule_relative_url "(null)" "$(pwd)/submodule" "../submodule" "$(pwd)/submodule"
368test_submodule_relative_url "(null)" "$(pwd)/home2/../remote" "../bundle1" "$(pwd)/home2/../bundle1"
369test_submodule_relative_url "(null)" "$(pwd)/submodule_update_repo" "./." "$(pwd)/submodule_update_repo/."
63e95beb
SB
370test_submodule_relative_url "(null)" "file:///tmp/repo" "../subrepo" "file:///tmp/subrepo"
371test_submodule_relative_url "(null)" "foo/bar" "../submodule" "foo/submodule"
372test_submodule_relative_url "(null)" "foo" "../submodule" "submodule"
373test_submodule_relative_url "(null)" "helper:://hostname/repo" "../subrepo" "helper:://hostname/subrepo"
2711b1ad
ÆAB
374test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../subrepo" "helper:://subrepo"
375test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../subrepo" "helper::/subrepo"
376test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../../subrepo" "helper::subrepo"
377test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../../../subrepo" "helper:subrepo"
378test_submodule_relative_url "(null)" "helper:://hostname/repo" "../../../../../../subrepo" ".:subrepo"
63e95beb 379test_submodule_relative_url "(null)" "ssh://hostname/repo" "../subrepo" "ssh://hostname/subrepo"
2711b1ad
ÆAB
380test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../subrepo" "ssh://subrepo"
381test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../../subrepo" "ssh:/subrepo"
382test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../../../subrepo" "ssh:subrepo"
383test_submodule_relative_url "(null)" "ssh://hostname/repo" "../../../../../subrepo" ".:subrepo"
63e95beb
SB
384test_submodule_relative_url "(null)" "ssh://hostname:22/repo" "../subrepo" "ssh://hostname:22/subrepo"
385test_submodule_relative_url "(null)" "user@host:path/to/repo" "../subrepo" "user@host:path/to/subrepo"
386test_submodule_relative_url "(null)" "user@host:repo" "../subrepo" "user@host:subrepo"
2711b1ad 387test_submodule_relative_url "(null)" "user@host:repo" "../../subrepo" ".:subrepo"
63e95beb 388
dc2d9ba3 389test_expect_success 'match .gitmodules' '
7913f53b 390 test-tool path-utils is_dotgitmodules \
dc2d9ba3
JS
391 .gitmodules \
392 \
393 .git${u200c}modules \
394 \
395 .Gitmodules \
396 .gitmoduleS \
397 \
398 ".gitmodules " \
399 ".gitmodules." \
400 ".gitmodules " \
401 ".gitmodules. " \
402 ".gitmodules ." \
403 ".gitmodules.." \
404 ".gitmodules " \
405 ".gitmodules. " \
406 ".gitmodules . " \
407 ".gitmodules ." \
408 \
409 ".Gitmodules " \
410 ".Gitmodules." \
411 ".Gitmodules " \
412 ".Gitmodules. " \
413 ".Gitmodules ." \
414 ".Gitmodules.." \
415 ".Gitmodules " \
416 ".Gitmodules. " \
417 ".Gitmodules . " \
418 ".Gitmodules ." \
419 \
420 GITMOD~1 \
421 gitmod~1 \
422 GITMOD~2 \
423 gitmod~3 \
424 GITMOD~4 \
425 \
426 "GITMOD~1 " \
427 "gitmod~2." \
428 "GITMOD~3 " \
429 "gitmod~4. " \
430 "GITMOD~1 ." \
431 "gitmod~2 " \
432 "GITMOD~3. " \
433 "gitmod~4 . " \
434 \
435 GI7EBA~1 \
436 gi7eba~9 \
437 \
438 GI7EB~10 \
439 GI7EB~11 \
440 GI7EB~99 \
441 GI7EB~10 \
442 GI7E~100 \
443 GI7E~101 \
444 GI7E~999 \
445 ~1000000 \
446 ~9999999 \
447 \
91bd4658
JS
448 .gitmodules:\$DATA \
449 "gitmod~4 . :\$DATA" \
450 \
dc2d9ba3
JS
451 --not \
452 ".gitmodules x" \
453 ".gitmodules .x" \
454 \
455 " .gitmodules" \
456 \
457 ..gitmodules \
458 \
459 gitmodules \
460 \
461 .gitmodule \
462 \
463 ".gitmodules x " \
464 ".gitmodules .x" \
465 \
466 GI7EBA~ \
467 GI7EBA~0 \
468 GI7EBA~~1 \
469 GI7EBA~X \
470 Gx7EBA~1 \
471 GI7EBX~1 \
472 \
473 GI7EB~1 \
474 GI7EB~01 \
91bd4658
JS
475 GI7EB~1X \
476 \
477 .gitmodules,:\$DATA
dc2d9ba3
JS
478'
479
801ed010
JK
480test_expect_success 'match .gitattributes' '
481 test-tool path-utils is_dotgitattributes \
482 .gitattributes \
483 .git${u200c}attributes \
484 .Gitattributes \
485 .gitattributeS \
486 GITATT~1 \
487 GI7D29~1
488'
489
490test_expect_success 'match .gitignore' '
491 test-tool path-utils is_dotgitignore \
492 .gitignore \
493 .git${u200c}ignore \
494 .Gitignore \
495 .gitignorE \
496 GITIGN~1 \
497 GI250A~1
498'
499
500test_expect_success 'match .mailmap' '
501 test-tool path-utils is_dotmailmap \
502 .mailmap \
503 .mail${u200c}map \
504 .Mailmap \
505 .mailmaP \
506 MAILMA~1 \
507 MABA30~1
508'
509
d2c84dad 510test_expect_success MINGW 'is_valid_path() on Windows' '
4dc42c6c 511 test-tool path-utils is_valid_path \
d2c84dad
JS
512 win32 \
513 "win32 x" \
514 ../hello.txt \
817ddd64 515 C:\\git \
4dc42c6c
JS
516 comm \
517 conout.c \
b6852e19 518 com0.c \
4dc42c6c 519 lptN \
d2c84dad
JS
520 \
521 --not \
522 "win32 " \
523 "win32 /x " \
524 "win32." \
525 "win32 . ." \
817ddd64 526 .../hello.txt \
4dc42c6c
JS
527 colon:test \
528 "AUX.c" \
529 "abc/conOut\$ .xyz/test" \
530 lpt8 \
b6852e19 531 com9.c \
4dc42c6c
JS
532 "lpt*" \
533 Nul \
534 "PRN./abc"
dc2d9ba3
JS
535'
536
b7d11a0f
JS
537test_lazy_prereq RUNTIME_PREFIX '
538 test true = "$RUNTIME_PREFIX"
539'
540
541test_lazy_prereq CAN_EXEC_IN_PWD '
542 cp "$GIT_EXEC_PATH"/git$X ./ &&
543 ./git rev-parse
544'
545
58407e04 546test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX works' '
b7d11a0f
JS
547 mkdir -p pretend/bin pretend/libexec/git-core &&
548 echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
549 cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
550 GIT_EXEC_PATH= ./pretend/bin/git here >actual &&
551 echo HERE >expect &&
e394a160
JS
552 test_cmp expect actual'
553
58407e04 554test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' '
e394a160
JS
555 mkdir -p pretend/bin &&
556 cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
557 git config yes.path "%(prefix)/yes" &&
558 GIT_EXEC_PATH= ./pretend/bin/git config --path yes.path >actual &&
559 echo "$(pwd)/pretend/yes" >expect &&
b7d11a0f
JS
560 test_cmp expect actual
561'
562
ae299be0 563test_done