@@ -14,48 +14,60 @@ impl RefSpecRef<'_> {
14
14
fn has_pattern ( item : & BStr ) -> bool {
15
15
item. contains ( & b'*' )
16
16
}
17
- match ( self . op , self . mode , self . src , self . dst ) {
18
- ( Operation :: Fetch , Mode :: Normal | Mode :: Force , Some ( src) , None ) => Instruction :: Fetch ( Fetch :: Only { src } ) ,
19
- ( Operation :: Fetch , Mode :: Normal | Mode :: Force , Some ( src) , Some ( dst ) ) => {
20
- Instruction :: Fetch ( Fetch :: AndUpdateSingle {
17
+ match self . op {
18
+ Operation :: Fetch => match ( self . mode , self . src , self . dst ) {
19
+ ( Mode :: Normal | Mode :: Force , Some ( src) , None ) => Instruction :: Fetch ( Fetch :: Only { src } ) ,
20
+ ( Mode :: Normal | Mode :: Force , Some ( src ) , Some ( dst ) ) => Instruction :: Fetch ( Fetch :: AndUpdateSingle {
21
21
src,
22
22
dst,
23
23
allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
24
- } )
25
- }
26
- ( Operation :: Push , Mode :: Normal | Mode :: Force , Some ( src) , None ) => Instruction :: Push ( Push :: Single {
27
- src,
28
- dst : src,
29
- allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
30
- } ) ,
31
- ( Operation :: Push , Mode :: Normal | Mode :: Force , None , Some ( dst) ) => {
32
- Instruction :: Push ( Push :: Delete { ref_or_pattern : dst } )
33
- }
34
- ( Operation :: Push , Mode :: Normal | Mode :: Force , None , None ) => Instruction :: Push ( Push :: AllMatchingBranches {
35
- allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
36
- } ) ,
37
- ( Operation :: Push , Mode :: Normal | Mode :: Force , Some ( src) , Some ( dst) ) if has_pattern ( src) => {
38
- Instruction :: Push ( Push :: MultipleWithGlob {
24
+ } ) ,
25
+ ( Mode :: Negative , Some ( src) , None ) if has_pattern ( src) => {
26
+ Instruction :: Fetch ( Fetch :: ExcludeMultipleWithGlob { src } )
27
+ }
28
+ ( Mode :: Negative , Some ( src) , None ) => Instruction :: Fetch ( Fetch :: ExcludeSingle { src } ) ,
29
+ ( mode, src, dest) => {
30
+ unreachable ! (
31
+ "BUG: fetch instructions with {:?} {:?} {:?} are not possible" ,
32
+ mode, src, dest
33
+ )
34
+ }
35
+ } ,
36
+ Operation :: Push => match ( self . mode , self . src , self . dst ) {
37
+ ( Mode :: Normal | Mode :: Force , Some ( src) , None ) => Instruction :: Push ( Push :: Single {
38
+ src,
39
+ dst : src,
40
+ allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
41
+ } ) ,
42
+ ( Mode :: Normal | Mode :: Force , None , Some ( dst) ) => {
43
+ Instruction :: Push ( Push :: Delete { ref_or_pattern : dst } )
44
+ }
45
+ ( Mode :: Normal | Mode :: Force , None , None ) => Instruction :: Push ( Push :: AllMatchingBranches {
46
+ allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
47
+ } ) ,
48
+ ( Mode :: Normal | Mode :: Force , Some ( src) , Some ( dst) ) if has_pattern ( src) => {
49
+ Instruction :: Push ( Push :: MultipleWithGlob {
50
+ src,
51
+ dst,
52
+ allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
53
+ } )
54
+ }
55
+ ( Mode :: Normal | Mode :: Force , Some ( src) , Some ( dst) ) => Instruction :: Push ( Push :: Single {
39
56
src,
40
57
dst,
41
58
allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
42
- } )
43
- }
44
- ( Operation :: Push , Mode :: Normal | Mode :: Force , Some ( src) , Some ( dst) ) => Instruction :: Push ( Push :: Single {
45
- src,
46
- dst,
47
- allow_non_fast_forward : matches ! ( self . mode, Mode :: Force ) ,
48
- } ) ,
49
- ( Operation :: Push , Mode :: Negative , Some ( src) , None ) if has_pattern ( src) => {
50
- Instruction :: Push ( Push :: ExcludeMultipleWithGlob { src } )
51
- }
52
- ( Operation :: Push , Mode :: Negative , Some ( src) , None ) => Instruction :: Push ( Push :: ExcludeSingle { src } ) ,
53
- ( op, mode, src, dest) => {
54
- unreachable ! (
55
- "BUG: instructions with {:?} {:?} {:?} {:?} are not possible" ,
56
- op, mode, src, dest
57
- )
58
- }
59
+ } ) ,
60
+ ( Mode :: Negative , Some ( src) , None ) if has_pattern ( src) => {
61
+ Instruction :: Push ( Push :: ExcludeMultipleWithGlob { src } )
62
+ }
63
+ ( Mode :: Negative , Some ( src) , None ) => Instruction :: Push ( Push :: ExcludeSingle { src } ) ,
64
+ ( mode, src, dest) => {
65
+ unreachable ! (
66
+ "BUG: push instructions with {:?} {:?} {:?} are not possible" ,
67
+ mode, src, dest
68
+ )
69
+ }
70
+ } ,
59
71
}
60
72
}
61
73
}
0 commit comments