@@ -16,14 +16,22 @@ impl<'a> MatchGroup<'a> {
16
16
specs : specs. into_iter ( ) . filter ( |s| s. op == Operation :: Fetch ) . collect ( ) ,
17
17
}
18
18
}
19
+
20
+ /// Take all the push ref specs from `specs` get a match group ready.
21
+ pub fn from_push_specs ( specs : impl IntoIterator < Item = RefSpecRef < ' a > > ) -> Self {
22
+ MatchGroup {
23
+ specs : specs. into_iter ( ) . filter ( |s| s. op == Operation :: Push ) . collect ( ) ,
24
+ }
25
+ }
19
26
}
20
27
21
28
/// Matching
22
29
impl < ' a > MatchGroup < ' a > {
23
- /// Match all `items` against all fetch specs present in this group, returning deduplicated mappings from source to destination.
24
- /// Note that this method only makes sense if the specs are indeed fetch specs and may panic otherwise .
30
+ /// Match all `items` against all * fetch* specs present in this group, returning deduplicated mappings from source to destination.
31
+ /// * Note that this method is correct only for specs*, even though it also *works for push-specs* .
25
32
///
26
33
/// Note that negative matches are not part of the return value, so they are not observable but will be used to remove mappings.
34
+ // TODO: figure out how to deal with push-specs, probably when push is being implemented.
27
35
pub fn match_remotes < ' item > ( self , mut items : impl Iterator < Item = Item < ' item > > + Clone ) -> Outcome < ' a , ' item > {
28
36
let mut out = Vec :: new ( ) ;
29
37
let mut seen = BTreeSet :: default ( ) ;
@@ -54,11 +62,11 @@ impl<'a> MatchGroup<'a> {
54
62
55
63
let mut has_negation = false ;
56
64
for ( spec_index, ( spec, matcher) ) in self . specs . iter ( ) . zip ( matchers. iter_mut ( ) ) . enumerate ( ) {
65
+ if spec. mode == Mode :: Negative {
66
+ has_negation = true ;
67
+ continue ;
68
+ }
57
69
for ( item_index, item) in items. clone ( ) . enumerate ( ) {
58
- if spec. mode == Mode :: Negative {
59
- has_negation = true ;
60
- continue ;
61
- }
62
70
if let Some ( matcher) = matcher {
63
71
let ( matched, rhs) = matcher. matches_lhs ( item) ;
64
72
if matched {
@@ -73,8 +81,8 @@ impl<'a> MatchGroup<'a> {
73
81
}
74
82
}
75
83
76
- if let Some ( id ) = has_negation. then ( || items. next ( ) . map ( |i| i. target ) ) . flatten ( ) {
77
- let null_id = gix_hash :: ObjectId :: null ( id . kind ( ) ) ;
84
+ if let Some ( hash_kind ) = has_negation. then ( || items. next ( ) . map ( |i| i. target . kind ( ) ) ) . flatten ( ) {
85
+ let null_id = hash_kind . null ( ) ;
78
86
for matcher in matchers
79
87
. into_iter ( )
80
88
. zip ( self . specs . iter ( ) )
0 commit comments