Set TEST_DIRECTORY
[git.git] / t / t1504-ceiling-dirs.sh
blobcce87a5ab523d3a4232e9e11863aa3a6e8ca0211
1 #!/bin/sh
3 test_description='test GIT_CEILING_DIRECTORIES'
4 . ./test-lib.sh
6 test_prefix() {
7 test_expect_success "$1" \
8 "test '$2' = \"\$(git rev-parse --show-prefix)\""
11 test_fail() {
12 test_expect_success "$1: prefix" '
13 test_expect_code 128 git rev-parse --show-prefix
17 TRASH_ROOT="$PWD"
18 ROOT_PARENT=$(dirname "$TRASH_ROOT")
21 unset GIT_CEILING_DIRECTORIES
22 test_prefix no_ceil ""
24 export GIT_CEILING_DIRECTORIES
26 GIT_CEILING_DIRECTORIES=""
27 test_prefix ceil_empty ""
29 GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
30 test_prefix ceil_at_parent ""
32 GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
33 test_prefix ceil_at_parent_slash ""
35 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
36 test_prefix ceil_at_trash ""
38 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
39 test_prefix ceil_at_trash_slash ""
41 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
42 test_prefix ceil_at_sub ""
44 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
45 test_prefix ceil_at_sub_slash ""
48 mkdir -p sub/dir || exit 1
49 cd sub/dir || exit 1
51 unset GIT_CEILING_DIRECTORIES
52 test_prefix subdir_no_ceil "sub/dir/"
54 export GIT_CEILING_DIRECTORIES
56 GIT_CEILING_DIRECTORIES=""
57 test_prefix subdir_ceil_empty "sub/dir/"
59 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
60 test_fail subdir_ceil_at_trash
62 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
63 test_fail subdir_ceil_at_trash_slash
65 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
66 test_fail subdir_ceil_at_sub
68 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
69 test_fail subdir_ceil_at_sub_slash
71 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
72 test_prefix subdir_ceil_at_subdir "sub/dir/"
74 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
75 test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
78 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
79 test_prefix subdir_ceil_at_su "sub/dir/"
81 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
82 test_prefix subdir_ceil_at_su_slash "sub/dir/"
84 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
85 test_prefix subdir_ceil_at_sub_di "sub/dir/"
87 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
88 test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
90 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
91 test_prefix subdir_ceil_at_subdi "sub/dir/"
93 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
94 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
97 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
98 test_fail second_of_two
100 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
101 test_fail first_of_two
103 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
104 test_fail second_of_three
107 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
108 GIT_DIR=../../.git
109 export GIT_DIR
110 test_prefix git_dir_specified ""
111 unset GIT_DIR
114 cd ../.. || exit 1
115 mkdir -p s/d || exit 1
116 cd s/d || exit 1
118 unset GIT_CEILING_DIRECTORIES
119 test_prefix sd_no_ceil "s/d/"
121 export GIT_CEILING_DIRECTORIES
123 GIT_CEILING_DIRECTORIES=""
124 test_prefix sd_ceil_empty "s/d/"
126 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
127 test_fail sd_ceil_at_trash
129 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
130 test_fail sd_ceil_at_trash_slash
132 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
133 test_fail sd_ceil_at_s
135 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
136 test_fail sd_ceil_at_s_slash
138 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
139 test_prefix sd_ceil_at_sd "s/d/"
141 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
142 test_prefix sd_ceil_at_sd_slash "s/d/"
145 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
146 test_prefix sd_ceil_at_su "s/d/"
148 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
149 test_prefix sd_ceil_at_su_slash "s/d/"
151 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
152 test_prefix sd_ceil_at_s_di "s/d/"
154 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
155 test_prefix sd_ceil_at_s_di_slash "s/d/"
157 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
158 test_prefix sd_ceil_at_sdi "s/d/"
160 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
161 test_prefix sd_ceil_at_sdi_slash "s/d/"
164 test_done