@@ -5,38 +5,40 @@ test_description='Test git check-ref-format'
55. ./test-lib.sh
66
77valid_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+ "
1617}
1718invalid_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+ "
2628}
2729
2830invalid_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'
3335valid_ref ' foo/bar/baz'
3436valid_ref ' foo/bar/baz' --normalize
3537invalid_ref ' refs///heads/foo'
3638valid_ref ' refs///heads/foo' --normalize
3739invalid_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
4042invalid_ref ' ///heads/foo'
4143valid_ref ' ///heads/foo' --normalize
4244invalid_ref ' ./foo'
@@ -115,14 +117,14 @@ invalid_ref "$ref" --refspec-pattern
115117invalid_ref " $ref " ' --refspec-pattern --allow-onelevel'
116118
117119ref=' /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'
126128
127129test_expect_success " check-ref-format --branch @{-1}" '
128130 T=$(git write-tree) &&
@@ -155,21 +157,35 @@ test_expect_success 'check-ref-format --branch from subdir' '
155157'
156158
157159valid_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 '" "
159167 refname=\$ (git check-ref-format --normalize '$1 ') &&
160- test \"\$ refname\" = '$2 '"
168+ test \"\$ refname\" = '$2 '
169+ "
161170}
162171invalid_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+ "
165181}
166182
167183valid_ref_normalized ' heads/foo' ' heads/foo'
168184valid_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'
170186valid_ref_normalized ' ///heads/foo' ' heads/foo'
171187invalid_ref_normalized ' foo'
172- invalid_ref_normalized ' /foo'
188+ invalid_ref_normalized NOT_MINGW ' /foo'
173189invalid_ref_normalized ' heads/foo/../bar'
174190invalid_ref_normalized ' heads/./foo'
175191invalid_ref_normalized ' heads\foo'
0 commit comments