Merge branch 'ms/rebase-insnformat-doc-fix' into maint-2.43
[git.git] / t / t1504-ceiling-dirs.sh
blobc1679e31d8afca409323484d588bf63b264f45f2
1 #!/bin/sh
3 test_description='test GIT_CEILING_DIRECTORIES'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_prefix() {
9 local expect="$2" &&
10 test_expect_success "$1: git rev-parse --show-prefix is '$2'" '
11 echo "$expect" >expect &&
12 git rev-parse --show-prefix >actual &&
13 test_cmp expect actual
17 test_fail() {
18 test_expect_success "$1: prefix" '
19 test_expect_code 128 git rev-parse --show-prefix
23 TRASH_ROOT="$PWD"
24 ROOT_PARENT=$(dirname "$TRASH_ROOT")
27 unset GIT_CEILING_DIRECTORIES
28 test_prefix no_ceil ""
30 export GIT_CEILING_DIRECTORIES
32 GIT_CEILING_DIRECTORIES=""
33 test_prefix ceil_empty ""
35 GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
36 test_prefix ceil_at_parent ""
38 GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
39 test_prefix ceil_at_parent_slash ""
41 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
42 test_prefix ceil_at_trash ""
44 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
45 test_prefix ceil_at_trash_slash ""
47 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
48 test_prefix ceil_at_sub ""
50 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
51 test_prefix ceil_at_sub_slash ""
53 if test_have_prereq SYMLINKS
54 then
55 ln -s sub top
58 mkdir -p sub/dir || exit 1
59 cd sub/dir || exit 1
61 unset GIT_CEILING_DIRECTORIES
62 test_prefix subdir_no_ceil "sub/dir/"
64 export GIT_CEILING_DIRECTORIES
66 GIT_CEILING_DIRECTORIES=""
67 test_prefix subdir_ceil_empty "sub/dir/"
69 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
70 test_fail subdir_ceil_at_trash
72 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
73 test_fail subdir_ceil_at_trash_slash
75 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
76 test_fail subdir_ceil_at_sub
78 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
79 test_fail subdir_ceil_at_sub_slash
81 if test_have_prereq SYMLINKS
82 then
83 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top"
84 test_fail subdir_ceil_at_top
85 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
86 test_fail subdir_ceil_at_top_slash
88 GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
89 test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
90 GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
91 test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
94 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
95 test_prefix subdir_ceil_at_subdir "sub/dir/"
97 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
98 test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
101 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
102 test_prefix subdir_ceil_at_su "sub/dir/"
104 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
105 test_prefix subdir_ceil_at_su_slash "sub/dir/"
107 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
108 test_prefix subdir_ceil_at_sub_di "sub/dir/"
110 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
111 test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
113 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
114 test_prefix subdir_ceil_at_subdi "sub/dir/"
116 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
117 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
120 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
121 test_fail second_of_two
123 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
124 test_fail first_of_two
126 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
127 test_fail second_of_three
130 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
131 GIT_DIR=../../.git
132 export GIT_DIR
133 test_prefix git_dir_specified ""
134 unset GIT_DIR
137 cd ../.. || exit 1
138 mkdir -p s/d || exit 1
139 cd s/d || exit 1
141 unset GIT_CEILING_DIRECTORIES
142 test_prefix sd_no_ceil "s/d/"
144 export GIT_CEILING_DIRECTORIES
146 GIT_CEILING_DIRECTORIES=""
147 test_prefix sd_ceil_empty "s/d/"
149 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
150 test_fail sd_ceil_at_trash
152 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
153 test_fail sd_ceil_at_trash_slash
155 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
156 test_fail sd_ceil_at_s
158 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
159 test_fail sd_ceil_at_s_slash
161 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
162 test_prefix sd_ceil_at_sd "s/d/"
164 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
165 test_prefix sd_ceil_at_sd_slash "s/d/"
168 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
169 test_prefix sd_ceil_at_su "s/d/"
171 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
172 test_prefix sd_ceil_at_su_slash "s/d/"
174 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
175 test_prefix sd_ceil_at_s_di "s/d/"
177 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
178 test_prefix sd_ceil_at_s_di_slash "s/d/"
180 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
181 test_prefix sd_ceil_at_sdi "s/d/"
183 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
184 test_prefix sd_ceil_at_sdi_slash "s/d/"
187 test_done