@@ -24,6 +24,83 @@ pub enum Operation {
24
24
Fetch ,
25
25
}
26
26
27
+ pub enum Instruction < ' a > {
28
+ Push ( Push < ' a > ) ,
29
+ Fetch ( Fetch < ' a > ) ,
30
+ }
31
+
32
+ pub enum Push < ' a > {
33
+ /// Push a single ref knowing only one ref name.
34
+ SingleMatching {
35
+ /// The name of the ref to push from `src` to `dest`.
36
+ src_and_dest : & ' a BStr ,
37
+ /// If true, allow non-fast-forward updates of `dest`.
38
+ allow_non_fast_forward : bool ,
39
+ } ,
40
+ /// Exclude a single ref.
41
+ ExcludeSingle {
42
+ /// A single full ref name to exclude.
43
+ src : & ' a BStr ,
44
+ } ,
45
+ /// Exclude multiple refs with single `*` glob.
46
+ ExcludeMultipleWithGlob {
47
+ /// A ref pattern with a single `*`.
48
+ src : & ' a BStr ,
49
+ } ,
50
+ /// Push a single ref or refspec to a known destination ref.
51
+ Single {
52
+ /// The source ref or refspec to push.
53
+ src : & ' a BStr ,
54
+ /// The ref to update with the object from `src`.
55
+ dest : & ' a BStr ,
56
+ /// If true, allow non-fast-forward updates of `dest`.
57
+ allow_non_fast_forward : bool ,
58
+ } ,
59
+ /// Push a multiple refs to matching destination refs, with exactly a single glob on both sides.
60
+ MultipleWithGlob {
61
+ /// The source ref to match against all refs for pushing.
62
+ src : & ' a BStr ,
63
+ /// The ref to update with object obtained from `src`, filling in the `*` with the portion that matched in `src`.
64
+ dest : & ' a BStr ,
65
+ /// If true, allow non-fast-forward updates of `dest`.
66
+ allow_non_fast_forward : bool ,
67
+ } ,
68
+ }
69
+
70
+ pub enum Fetch < ' a > {
71
+ Only {
72
+ /// The ref name to fetch on the remote side, without updating the local side.
73
+ src : & ' a BStr ,
74
+ } ,
75
+ /// Exclude a single ref.
76
+ ExcludeSingle {
77
+ /// A single full ref name to exclude.
78
+ src : & ' a BStr ,
79
+ } ,
80
+ /// Exclude multiple refs with single `*` glob.
81
+ ExcludeMultipleWithGlob {
82
+ /// A ref pattern with a single `*`.
83
+ src : & ' a BStr ,
84
+ } ,
85
+ AndUpdateSingle {
86
+ /// The ref name to fetch on the remote side.
87
+ src : & ' a BStr ,
88
+ /// The local destination to update with what was fetched.
89
+ dest : & ' a BStr ,
90
+ /// If true, allow non-fast-forward updates of `dest`.
91
+ allow_non_fast_forward : bool ,
92
+ } ,
93
+ /// Similar to `FetchAndUpdate`, but src and destination contain a single glob to fetch and update multiple refs.
94
+ AndUpdateMultipleWithGlob {
95
+ /// The ref glob to match against all refs on the remote side for fetching.
96
+ src : & ' a BStr ,
97
+ /// The local destination to update with what was fetched by replacing the single `*` with the matching portion from `src`.
98
+ dest : & ' a BStr ,
99
+ /// If true, allow non-fast-forward updates of `dest`.
100
+ allow_non_fast_forward : bool ,
101
+ } ,
102
+ }
103
+
27
104
/// A refspec with references to the memory it was parsed from.
28
105
#[ derive( PartialEq , Eq , Copy , Clone , Hash , Debug ) ]
29
106
pub struct RefSpecRef < ' a > {
@@ -46,8 +123,22 @@ pub mod parse;
46
123
pub use parse:: function:: parse;
47
124
48
125
mod spec {
49
- use crate :: { RefSpec , RefSpecRef } ;
126
+ use crate :: { Instruction , Mode , RefSpec , RefSpecRef } ;
127
+
128
+ /// Access
129
+ impl RefSpecRef < ' _ > {
130
+ /// Return the refspec mode.
131
+ pub fn mode ( & self ) -> Mode {
132
+ self . mode
133
+ }
134
+
135
+ /// Transform the state of the refspec into an instruction making clear what to do with it.
136
+ pub fn instruction ( & self ) -> Instruction < ' _ > {
137
+ todo ! ( )
138
+ }
139
+ }
50
140
141
+ /// Conversion
51
142
impl RefSpecRef < ' _ > {
52
143
/// Convert this ref into a standalone, owned copy.
53
144
pub fn to_owned ( & self ) -> RefSpec {
0 commit comments