Skip to content

Commit 7f8a938

Browse files
committed
Merge branch 'js/check-ref-format-test-mingw'
* js/check-ref-format-test-mingw: t1402-check-ref-format: skip tests of refs beginning with slash on Windows
2 parents f2b5163 + 42afe62 commit 7f8a938

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

t/t1402-check-ref-format.sh

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,40 @@ test_description='Test git check-ref-format'
55
. ./test-lib.sh
66

77
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+
"
1617
}
1718
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+
"
2628
}
2729

2830
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'
3335
valid_ref 'foo/bar/baz'
3436
valid_ref 'foo/bar/baz' --normalize
3537
invalid_ref 'refs///heads/foo'
3638
valid_ref 'refs///heads/foo' --normalize
3739
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
4042
invalid_ref '///heads/foo'
4143
valid_ref '///heads/foo' --normalize
4244
invalid_ref './foo'
@@ -115,14 +117,14 @@ invalid_ref "$ref" --refspec-pattern
115117
invalid_ref "$ref" '--refspec-pattern --allow-onelevel'
116118

117119
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'
126128

127129
test_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

157159
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'" "
159167
refname=\$(git check-ref-format --normalize '$1') &&
160-
test \"\$refname\" = '$2'"
168+
test \"\$refname\" = '$2'
169+
"
161170
}
162171
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+
"
165181
}
166182

167183
valid_ref_normalized 'heads/foo' 'heads/foo'
168184
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'
170186
valid_ref_normalized '///heads/foo' 'heads/foo'
171187
invalid_ref_normalized 'foo'
172-
invalid_ref_normalized '/foo'
188+
invalid_ref_normalized NOT_MINGW '/foo'
173189
invalid_ref_normalized 'heads/foo/../bar'
174190
invalid_ref_normalized 'heads/./foo'
175191
invalid_ref_normalized 'heads\foo'

0 commit comments

Comments
 (0)