Code

Merge branch 'ja/fetch-doc' into maint
[git.git] / t / t1504-ceiling-dirs.sh
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)\""
9 }
11 test_fail() {
12         test_expect_code 128 "$1: prefix" \
13         "git rev-parse --show-prefix"
14 }
16 TRASH_ROOT="$PWD"
17 ROOT_PARENT=$(dirname "$TRASH_ROOT")
20 unset GIT_CEILING_DIRECTORIES
21 test_prefix no_ceil ""
23 export GIT_CEILING_DIRECTORIES
25 GIT_CEILING_DIRECTORIES=""
26 test_prefix ceil_empty ""
28 GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
29 test_prefix ceil_at_parent ""
31 GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
32 test_prefix ceil_at_parent_slash ""
34 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
35 test_prefix ceil_at_trash ""
37 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
38 test_prefix ceil_at_trash_slash ""
40 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
41 test_prefix ceil_at_sub ""
43 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
44 test_prefix ceil_at_sub_slash ""
47 mkdir -p sub/dir || exit 1
48 cd sub/dir || exit 1
50 unset GIT_CEILING_DIRECTORIES
51 test_prefix subdir_no_ceil "sub/dir/"
53 export GIT_CEILING_DIRECTORIES
55 GIT_CEILING_DIRECTORIES=""
56 test_prefix subdir_ceil_empty "sub/dir/"
58 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
59 test_fail subdir_ceil_at_trash
61 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
62 test_fail subdir_ceil_at_trash_slash
64 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
65 test_fail subdir_ceil_at_sub
67 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
68 test_fail subdir_ceil_at_sub_slash
70 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
71 test_prefix subdir_ceil_at_subdir "sub/dir/"
73 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
74 test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
77 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
78 test_prefix subdir_ceil_at_su "sub/dir/"
80 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
81 test_prefix subdir_ceil_at_su_slash "sub/dir/"
83 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
84 test_prefix subdir_ceil_at_sub_di "sub/dir/"
86 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
87 test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
89 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
90 test_prefix subdir_ceil_at_subdi "sub/dir/"
92 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
93 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
96 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
97 test_fail second_of_two
99 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
100 test_fail first_of_two
102 GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
103 test_fail second_of_three
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
113 cd ../.. || exit 1
114 mkdir -p s/d || exit 1
115 cd s/d || exit 1
117 unset GIT_CEILING_DIRECTORIES
118 test_prefix sd_no_ceil "s/d/"
120 export GIT_CEILING_DIRECTORIES
122 GIT_CEILING_DIRECTORIES=""
123 test_prefix sd_ceil_empty "s/d/"
125 GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
126 test_fail sd_ceil_at_trash
128 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
129 test_fail sd_ceil_at_trash_slash
131 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
132 test_fail sd_ceil_at_s
134 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
135 test_fail sd_ceil_at_s_slash
137 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
138 test_prefix sd_ceil_at_sd "s/d/"
140 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
141 test_prefix sd_ceil_at_sd_slash "s/d/"
144 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
145 test_prefix sd_ceil_at_su "s/d/"
147 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
148 test_prefix sd_ceil_at_su_slash "s/d/"
150 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
151 test_prefix sd_ceil_at_s_di "s/d/"
153 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
154 test_prefix sd_ceil_at_s_di_slash "s/d/"
156 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
157 test_prefix sd_ceil_at_sdi "s/d/"
159 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
160 test_prefix sd_ceil_at_sdi_slash "s/d/"
163 test_done