Merge branch 'jd/prompt-upstream-mark'
[alt-git.git] / t / t1504-ceiling-dirs.sh
blob0fafcf9dde385f2c2bac7fbd846098908a72f09b
1 #!/bin/sh
3 test_description='test GIT_CEILING_DIRECTORIES'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_prefix() {
9 test_expect_success "$1" \
10 "test '$2' = \"\$(git rev-parse --show-prefix)\""
13 test_fail() {
14 test_expect_success "$1: prefix" '
15 test_expect_code 128 git rev-parse --show-prefix
19 TRASH_ROOT="$PWD"
20 ROOT_PARENT=$(dirname "$TRASH_ROOT")
23 unset GIT_CEILING_DIRECTORIES
24 test_prefix no_ceil ""
26 export GIT_CEILING_DIRECTORIES
28 GIT_CEILING_DIRECTORIES=""
29 test_prefix ceil_empty ""
31 GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
32 test_prefix ceil_at_parent ""
34 GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
35 test_prefix ceil_at_parent_slash ""
37 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
38 test_prefix ceil_at_trash ""
40 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
41 test_prefix ceil_at_trash_slash ""
43 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
44 test_prefix ceil_at_sub ""
46 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
47 test_prefix ceil_at_sub_slash ""
49 if test_have_prereq SYMLINKS
50 then
51 ln -s sub top
54 mkdir -p sub/dir || exit 1
55 cd sub/dir || exit 1
57 unset GIT_CEILING_DIRECTORIES
58 test_prefix subdir_no_ceil "sub/dir/"
60 export GIT_CEILING_DIRECTORIES
62 GIT_CEILING_DIRECTORIES=""
63 test_prefix subdir_ceil_empty "sub/dir/"
65 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
66 test_fail subdir_ceil_at_trash
68 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
69 test_fail subdir_ceil_at_trash_slash
71 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
72 test_fail subdir_ceil_at_sub
74 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
75 test_fail subdir_ceil_at_sub_slash
77 if test_have_prereq SYMLINKS
78 then
79 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top"
80 test_fail subdir_ceil_at_top
81 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
82 test_fail subdir_ceil_at_top_slash
84 GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
85 test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
86 GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
87 test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
90 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
91 test_prefix subdir_ceil_at_subdir "sub/dir/"
93 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
94 test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
97 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
98 test_prefix subdir_ceil_at_su "sub/dir/"
100 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
101 test_prefix subdir_ceil_at_su_slash "sub/dir/"
103 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
104 test_prefix subdir_ceil_at_sub_di "sub/dir/"
106 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
107 test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
109 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
110 test_prefix subdir_ceil_at_subdi "sub/dir/"
112 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
113 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
116 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
117 test_fail second_of_two
119 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
120 test_fail first_of_two
122 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
123 test_fail second_of_three
126 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
127 GIT_DIR=../../.git
128 export GIT_DIR
129 test_prefix git_dir_specified ""
130 unset GIT_DIR
133 cd ../.. || exit 1
134 mkdir -p s/d || exit 1
135 cd s/d || exit 1
137 unset GIT_CEILING_DIRECTORIES
138 test_prefix sd_no_ceil "s/d/"
140 export GIT_CEILING_DIRECTORIES
142 GIT_CEILING_DIRECTORIES=""
143 test_prefix sd_ceil_empty "s/d/"
145 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
146 test_fail sd_ceil_at_trash
148 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
149 test_fail sd_ceil_at_trash_slash
151 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
152 test_fail sd_ceil_at_s
154 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
155 test_fail sd_ceil_at_s_slash
157 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
158 test_prefix sd_ceil_at_sd "s/d/"
160 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
161 test_prefix sd_ceil_at_sd_slash "s/d/"
164 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
165 test_prefix sd_ceil_at_su "s/d/"
167 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
168 test_prefix sd_ceil_at_su_slash "s/d/"
170 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
171 test_prefix sd_ceil_at_s_di "s/d/"
173 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
174 test_prefix sd_ceil_at_s_di_slash "s/d/"
176 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
177 test_prefix sd_ceil_at_sdi "s/d/"
179 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
180 test_prefix sd_ceil_at_sdi_slash "s/d/"
183 test_done