@@ -5,38 +5,40 @@ test_description='Test git check-ref-format'
5
5
. ./test-lib.sh
6
6
7
7
valid_ref () {
8
- if test " $# " = 1
9
- then
10
- test_expect_success " ref name '$1 ' is valid" \
11
- " git check-ref-format '$1 '"
12
- else
13
- test_expect_success " ref name '$1 ' is valid with options $2 " \
14
- " git check-ref-format $2 '$1 '"
15
- fi
8
+ prereq=
9
+ case $1 in
10
+ [A-Z]* )
11
+ prereq=$1
12
+ shift
13
+ esac
14
+ test_expect_success $prereq " ref name '$1 ' is valid${2: + with options $2 } " "
15
+ git check-ref-format $2 '$1 '
16
+ "
16
17
}
17
18
invalid_ref () {
18
- if test " $# " = 1
19
- then
20
- test_expect_success " ref name '$1 ' is invalid" \
21
- " test_must_fail git check-ref-format '$1 '"
22
- else
23
- test_expect_success " ref name '$1 ' is invalid with options $2 " \
24
- " test_must_fail git check-ref-format $2 '$1 '"
25
- fi
19
+ prereq=
20
+ case $1 in
21
+ [A-Z]* )
22
+ prereq=$1
23
+ shift
24
+ esac
25
+ test_expect_success $prereq " ref name '$1 ' is invalid${2: + with options $2 } " "
26
+ test_must_fail git check-ref-format $2 '$1 '
27
+ "
26
28
}
27
29
28
30
invalid_ref ' '
29
- invalid_ref ' /'
30
- invalid_ref ' /' --allow-onelevel
31
- invalid_ref ' /' --normalize
32
- invalid_ref ' /' ' --allow-onelevel --normalize'
31
+ invalid_ref NOT_MINGW ' /'
32
+ invalid_ref NOT_MINGW ' /' --allow-onelevel
33
+ invalid_ref NOT_MINGW ' /' --normalize
34
+ invalid_ref NOT_MINGW ' /' ' --allow-onelevel --normalize'
33
35
valid_ref ' foo/bar/baz'
34
36
valid_ref ' foo/bar/baz' --normalize
35
37
invalid_ref ' refs///heads/foo'
36
38
valid_ref ' refs///heads/foo' --normalize
37
39
invalid_ref ' heads/foo/'
38
- invalid_ref ' /heads/foo'
39
- valid_ref ' /heads/foo' --normalize
40
+ invalid_ref NOT_MINGW ' /heads/foo'
41
+ valid_ref NOT_MINGW ' /heads/foo' --normalize
40
42
invalid_ref ' ///heads/foo'
41
43
valid_ref ' ///heads/foo' --normalize
42
44
invalid_ref ' ./foo'
@@ -115,14 +117,14 @@ invalid_ref "$ref" --refspec-pattern
115
117
invalid_ref " $ref " ' --refspec-pattern --allow-onelevel'
116
118
117
119
ref=' /foo'
118
- invalid_ref " $ref "
119
- invalid_ref " $ref " --allow-onelevel
120
- invalid_ref " $ref " --refspec-pattern
121
- invalid_ref " $ref " ' --refspec-pattern --allow-onelevel'
122
- invalid_ref " $ref " --normalize
123
- valid_ref " $ref " ' --allow-onelevel --normalize'
124
- invalid_ref " $ref " ' --refspec-pattern --normalize'
125
- valid_ref " $ref " ' --refspec-pattern --allow-onelevel --normalize'
120
+ invalid_ref NOT_MINGW " $ref "
121
+ invalid_ref NOT_MINGW " $ref " --allow-onelevel
122
+ invalid_ref NOT_MINGW " $ref " --refspec-pattern
123
+ invalid_ref NOT_MINGW " $ref " ' --refspec-pattern --allow-onelevel'
124
+ invalid_ref NOT_MINGW " $ref " --normalize
125
+ valid_ref NOT_MINGW " $ref " ' --allow-onelevel --normalize'
126
+ invalid_ref NOT_MINGW " $ref " ' --refspec-pattern --normalize'
127
+ valid_ref NOT_MINGW " $ref " ' --refspec-pattern --allow-onelevel --normalize'
126
128
127
129
test_expect_success " check-ref-format --branch @{-1}" '
128
130
T=$(git write-tree) &&
@@ -155,21 +157,35 @@ test_expect_success 'check-ref-format --branch from subdir' '
155
157
'
156
158
157
159
valid_ref_normalized () {
158
- test_expect_success " ref name '$1 ' simplifies to '$2 '" "
160
+ prereq=
161
+ case $1 in
162
+ [A-Z]* )
163
+ prereq=$1
164
+ shift
165
+ esac
166
+ test_expect_success $prereq " ref name '$1 ' simplifies to '$2 '" "
159
167
refname=\$ (git check-ref-format --normalize '$1 ') &&
160
- test \"\$ refname\" = '$2 '"
168
+ test \"\$ refname\" = '$2 '
169
+ "
161
170
}
162
171
invalid_ref_normalized () {
163
- test_expect_success " check-ref-format --normalize rejects '$1 '" "
164
- test_must_fail git check-ref-format --normalize '$1 '"
172
+ prereq=
173
+ case $1 in
174
+ [A-Z]* )
175
+ prereq=$1
176
+ shift
177
+ esac
178
+ test_expect_success $prereq " check-ref-format --normalize rejects '$1 '" "
179
+ test_must_fail git check-ref-format --normalize '$1 '
180
+ "
165
181
}
166
182
167
183
valid_ref_normalized ' heads/foo' ' heads/foo'
168
184
valid_ref_normalized ' refs///heads/foo' ' refs/heads/foo'
169
- valid_ref_normalized ' /heads/foo' ' heads/foo'
185
+ valid_ref_normalized NOT_MINGW ' /heads/foo' ' heads/foo'
170
186
valid_ref_normalized ' ///heads/foo' ' heads/foo'
171
187
invalid_ref_normalized ' foo'
172
- invalid_ref_normalized ' /foo'
188
+ invalid_ref_normalized NOT_MINGW ' /foo'
173
189
invalid_ref_normalized ' heads/foo/../bar'
174
190
invalid_ref_normalized ' heads/./foo'
175
191
invalid_ref_normalized ' heads\foo'
0 commit comments