summaryrefslogtreecommitdiff
path: root/t/t1504-ceiling-dirs.sh
blob: 91b704a3a4ce6771071d19bd84aa228856fe6875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/sh

test_description='test GIT_CEILING_DIRECTORIES'
. ./test-lib.sh

test_prefix() {
	test_expect_success "$1" \
	"test '$2' = \"\$(git rev-parse --show-prefix)\""
}

test_fail() {
	test_expect_code 128 "$1: prefix" \
	"git rev-parse --show-prefix"
}

TRASH_ROOT="$(pwd)"
ROOT_PARENT=$(dirname "$TRASH_ROOT")


unset GIT_CEILING_DIRECTORIES
test_prefix no_ceil ""

export GIT_CEILING_DIRECTORIES

GIT_CEILING_DIRECTORIES=""
test_prefix ceil_empty ""

GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
test_prefix ceil_at_parent ""

GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
test_prefix ceil_at_parent_slash ""

GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
test_prefix ceil_at_trash ""

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
test_prefix ceil_at_trash_slash ""

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
test_prefix ceil_at_sub ""

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
test_prefix ceil_at_sub_slash ""


mkdir -p sub/dir || exit 1
cd sub/dir || exit 1

unset GIT_CEILING_DIRECTORIES
test_prefix subdir_no_ceil "sub/dir/"

export GIT_CEILING_DIRECTORIES

GIT_CEILING_DIRECTORIES=""
test_prefix subdir_ceil_empty "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
test_fail subdir_ceil_at_trash

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
test_fail subdir_ceil_at_trash_slash

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
test_fail subdir_ceil_at_sub

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
test_fail subdir_ceil_at_sub_slash

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
test_prefix subdir_ceil_at_subdir "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
test_prefix subdir_ceil_at_subdir_slash "sub/dir/"


GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
test_prefix subdir_ceil_at_su "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
test_prefix subdir_ceil_at_su_slash "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
test_prefix subdir_ceil_at_sub_di "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
test_prefix subdir_ceil_at_subdi "sub/dir/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
test_prefix subdir_ceil_at_subdi_slash "sub/dir/"


GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
test_fail second_of_two

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
test_fail first_of_two

GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
test_fail second_of_three


GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
GIT_DIR=../../.git
export GIT_DIR
test_prefix git_dir_specified ""
unset GIT_DIR


cd ../.. || exit 1
mkdir -p s/d || exit 1
cd s/d || exit 1

unset GIT_CEILING_DIRECTORIES
test_prefix sd_no_ceil "s/d/"

export GIT_CEILING_DIRECTORIES

GIT_CEILING_DIRECTORIES=""
test_prefix sd_ceil_empty "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
test_fail sd_ceil_at_trash

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
test_fail sd_ceil_at_trash_slash

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
test_fail sd_ceil_at_s

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
test_fail sd_ceil_at_s_slash

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
test_prefix sd_ceil_at_sd "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
test_prefix sd_ceil_at_sd_slash "s/d/"


GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
test_prefix sd_ceil_at_su "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
test_prefix sd_ceil_at_su_slash "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
test_prefix sd_ceil_at_s_di "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
test_prefix sd_ceil_at_s_di_slash "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
test_prefix sd_ceil_at_sdi "s/d/"

GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
test_prefix sd_ceil_at_sdi_slash "s/d/"


test_done