Merge branch 'jc/revision-dash-count-parsing'
[git.git] / t / t1504-ceiling-dirs.sh
blob3d51615e42d53a0c7794533eb27049606981fbf3
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 ""
47 if test_have_prereq SYMLINKS
48 then
49 ln -s sub top
52 mkdir -p sub/dir || exit 1
53 cd sub/dir || exit 1
55 unset GIT_CEILING_DIRECTORIES
56 test_prefix subdir_no_ceil "sub/dir/"
58 export GIT_CEILING_DIRECTORIES
60 GIT_CEILING_DIRECTORIES=""
61 test_prefix subdir_ceil_empty "sub/dir/"
63 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
64 test_fail subdir_ceil_at_trash
66 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
67 test_fail subdir_ceil_at_trash_slash
69 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
70 test_fail subdir_ceil_at_sub
72 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
73 test_fail subdir_ceil_at_sub_slash
75 if test_have_prereq SYMLINKS
76 then
77 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top"
78 test_fail subdir_ceil_at_top
79 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
80 test_fail subdir_ceil_at_top_slash
82 GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
83 test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
84 GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
85 test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
88 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
89 test_prefix subdir_ceil_at_subdir "sub/dir/"
91 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
92 test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
95 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
96 test_prefix subdir_ceil_at_su "sub/dir/"
98 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
99 test_prefix subdir_ceil_at_su_slash "sub/dir/"
101 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
102 test_prefix subdir_ceil_at_sub_di "sub/dir/"
104 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
105 test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
107 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
108 test_prefix subdir_ceil_at_subdi "sub/dir/"
110 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
111 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
114 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
115 test_fail second_of_two
117 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
118 test_fail first_of_two
120 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
121 test_fail second_of_three
124 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
125 GIT_DIR=../../.git
126 export GIT_DIR
127 test_prefix git_dir_specified ""
128 unset GIT_DIR
131 cd ../.. || exit 1
132 mkdir -p s/d || exit 1
133 cd s/d || exit 1
135 unset GIT_CEILING_DIRECTORIES
136 test_prefix sd_no_ceil "s/d/"
138 export GIT_CEILING_DIRECTORIES
140 GIT_CEILING_DIRECTORIES=""
141 test_prefix sd_ceil_empty "s/d/"
143 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
144 test_fail sd_ceil_at_trash
146 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
147 test_fail sd_ceil_at_trash_slash
149 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
150 test_fail sd_ceil_at_s
152 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
153 test_fail sd_ceil_at_s_slash
155 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
156 test_prefix sd_ceil_at_sd "s/d/"
158 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
159 test_prefix sd_ceil_at_sd_slash "s/d/"
162 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
163 test_prefix sd_ceil_at_su "s/d/"
165 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
166 test_prefix sd_ceil_at_su_slash "s/d/"
168 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
169 test_prefix sd_ceil_at_s_di "s/d/"
171 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
172 test_prefix sd_ceil_at_s_di_slash "s/d/"
174 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
175 test_prefix sd_ceil_at_sdi "s/d/"
177 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
178 test_prefix sd_ceil_at_sdi_slash "s/d/"
181 test_done