Merge branch 'jc/maint-fix-mailinfo-strip'
[git] / t / t1504-ceiling-dirs.sh
1 #!/bin/sh
2
3 test_description='test GIT_CEILING_DIRECTORIES'
4 . ./test-lib.sh
5
6 test_prefix() {
7         test_expect_success "$1" \
8         "test '$2' = \"\$(git rev-parse --show-prefix)\""
9 }
10
11 test_fail() {
12         test_expect_code 128 "$1: prefix" \
13         "git rev-parse --show-prefix"
14 }
15
16 TRASH_ROOT="$PWD"
17 ROOT_PARENT=$(dirname "$TRASH_ROOT")
18
19
20 unset GIT_CEILING_DIRECTORIES
21 test_prefix no_ceil ""
22
23 export GIT_CEILING_DIRECTORIES
24
25 GIT_CEILING_DIRECTORIES=""
26 test_prefix ceil_empty ""
27
28 GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
29 test_prefix ceil_at_parent ""
30
31 GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
32 test_prefix ceil_at_parent_slash ""
33
34 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
35 test_prefix ceil_at_trash ""
36
37 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
38 test_prefix ceil_at_trash_slash ""
39
40 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
41 test_prefix ceil_at_sub ""
42
43 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
44 test_prefix ceil_at_sub_slash ""
45
46
47 mkdir -p sub/dir || exit 1
48 cd sub/dir || exit 1
49
50 unset GIT_CEILING_DIRECTORIES
51 test_prefix subdir_no_ceil "sub/dir/"
52
53 export GIT_CEILING_DIRECTORIES
54
55 GIT_CEILING_DIRECTORIES=""
56 test_prefix subdir_ceil_empty "sub/dir/"
57
58 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
59 test_fail subdir_ceil_at_trash
60
61 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
62 test_fail subdir_ceil_at_trash_slash
63
64 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
65 test_fail subdir_ceil_at_sub
66
67 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
68 test_fail subdir_ceil_at_sub_slash
69
70 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
71 test_prefix subdir_ceil_at_subdir "sub/dir/"
72
73 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
74 test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
75
76
77 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
78 test_prefix subdir_ceil_at_su "sub/dir/"
79
80 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
81 test_prefix subdir_ceil_at_su_slash "sub/dir/"
82
83 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
84 test_prefix subdir_ceil_at_sub_di "sub/dir/"
85
86 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
87 test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
88
89 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
90 test_prefix subdir_ceil_at_subdi "sub/dir/"
91
92 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
93 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
94
95
96 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
97 test_fail second_of_two
98
99 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
100 test_fail first_of_two
101
102 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
103 test_fail second_of_three
104
105
106 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
107 GIT_DIR=../../.git
108 export GIT_DIR
109 test_prefix git_dir_specified ""
110 unset GIT_DIR
111
112
113 cd ../.. || exit 1
114 mkdir -p s/d || exit 1
115 cd s/d || exit 1
116
117 unset GIT_CEILING_DIRECTORIES
118 test_prefix sd_no_ceil "s/d/"
119
120 export GIT_CEILING_DIRECTORIES
121
122 GIT_CEILING_DIRECTORIES=""
123 test_prefix sd_ceil_empty "s/d/"
124
125 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
126 test_fail sd_ceil_at_trash
127
128 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
129 test_fail sd_ceil_at_trash_slash
130
131 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
132 test_fail sd_ceil_at_s
133
134 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
135 test_fail sd_ceil_at_s_slash
136
137 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
138 test_prefix sd_ceil_at_sd "s/d/"
139
140 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
141 test_prefix sd_ceil_at_sd_slash "s/d/"
142
143
144 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
145 test_prefix sd_ceil_at_su "s/d/"
146
147 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
148 test_prefix sd_ceil_at_su_slash "s/d/"
149
150 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
151 test_prefix sd_ceil_at_s_di "s/d/"
152
153 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
154 test_prefix sd_ceil_at_s_di_slash "s/d/"
155
156 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
157 test_prefix sd_ceil_at_sdi "s/d/"
158
159 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
160 test_prefix sd_ceil_at_sdi_slash "s/d/"
161
162
163 test_done