@@ -31,7 +31,11 @@ fn baseline() {
31
31
let res = catch_unwind ( || try_parse ( spec. to_str ( ) . unwrap ( ) , op) ) ;
32
32
match res {
33
33
Ok ( res) => match ( res. is_ok ( ) , err_code == 0 ) {
34
- ( true , true ) | ( false , false ) => { }
34
+ ( true , true ) | ( false , false ) => {
35
+ if let Ok ( spec) = res {
36
+ spec. instruction ( ) ; // should not panic
37
+ }
38
+ }
35
39
_ => {
36
40
eprintln ! ( "{err_code} {res:?} {} {:?}" , kind. as_bstr( ) , spec. as_bstr( ) ) ;
37
41
mismatch += 1 ;
@@ -132,6 +136,46 @@ mod fetch {
132
136
) ;
133
137
}
134
138
139
+ #[ test]
140
+ fn lhs_colon_rhs_updates_single_ref ( ) {
141
+ assert_parse (
142
+ "a:b" ,
143
+ Instruction :: Fetch ( Fetch :: AndUpdateSingle {
144
+ src : b ( "a" ) ,
145
+ dst : b ( "b" ) ,
146
+ allow_non_fast_forward : false ,
147
+ } ) ,
148
+ ) ;
149
+ assert_parse (
150
+ "+a:b" ,
151
+ Instruction :: Fetch ( Fetch :: AndUpdateSingle {
152
+ src : b ( "a" ) ,
153
+ dst : b ( "b" ) ,
154
+ allow_non_fast_forward : true ,
155
+ } ) ,
156
+ ) ;
157
+ }
158
+
159
+ #[ test]
160
+ fn lhs_colon_rhs_with_glob_updates_multiple_refs ( ) {
161
+ assert_parse (
162
+ "a/*:b/*" ,
163
+ Instruction :: Fetch ( Fetch :: AndUpdateMultipleWithGlob {
164
+ src : b ( "a/*" ) ,
165
+ dst : b ( "b/*" ) ,
166
+ allow_non_fast_forward : false ,
167
+ } ) ,
168
+ ) ;
169
+ assert_parse (
170
+ "+a/*:b/*" ,
171
+ Instruction :: Fetch ( Fetch :: AndUpdateMultipleWithGlob {
172
+ src : b ( "a/*" ) ,
173
+ dst : b ( "b/*" ) ,
174
+ allow_non_fast_forward : true ,
175
+ } ) ,
176
+ ) ;
177
+ }
178
+
135
179
#[ test]
136
180
fn empty_lhs_colon_rhs_fetches_head_to_destination ( ) {
137
181
assert_parse (
@@ -180,6 +224,46 @@ mod push {
180
224
assert_parse ( "^a*" , Instruction :: Push ( Push :: ExcludeMultipleWithGlob { src : b ( "a*" ) } ) ) ;
181
225
}
182
226
227
+ #[ test]
228
+ fn lhs_colon_rhs_pushes_single_ref ( ) {
229
+ assert_parse (
230
+ "a:b" ,
231
+ Instruction :: Push ( Push :: Single {
232
+ src : b ( "a" ) ,
233
+ dst : b ( "b" ) ,
234
+ allow_non_fast_forward : false ,
235
+ } ) ,
236
+ ) ;
237
+ assert_parse (
238
+ "+a:b" ,
239
+ Instruction :: Push ( Push :: Single {
240
+ src : b ( "a" ) ,
241
+ dst : b ( "b" ) ,
242
+ allow_non_fast_forward : true ,
243
+ } ) ,
244
+ ) ;
245
+ }
246
+
247
+ #[ test]
248
+ fn lhs_colon_rhs_with_glob_pushes_multiple_refs ( ) {
249
+ assert_parse (
250
+ "a/*:b/*" ,
251
+ Instruction :: Push ( Push :: MultipleWithGlob {
252
+ src : b ( "a/*" ) ,
253
+ dst : b ( "b/*" ) ,
254
+ allow_non_fast_forward : false ,
255
+ } ) ,
256
+ ) ;
257
+ assert_parse (
258
+ "+a/*:b/*" ,
259
+ Instruction :: Push ( Push :: MultipleWithGlob {
260
+ src : b ( "a/*" ) ,
261
+ dst : b ( "b/*" ) ,
262
+ allow_non_fast_forward : true ,
263
+ } ) ,
264
+ ) ;
265
+ }
266
+
183
267
#[ test]
184
268
fn colon_alone_is_for_pushing_matching_refs ( ) {
185
269
assert_parse (
0 commit comments