@@ -2,7 +2,6 @@ use std::{borrow::Cow, collections::HashSet};
22
33use bstr:: { BString , ByteSlice , ByteVec } ;
44use gix_features:: progress:: Progress ;
5- use gix_refspec:: RefSpec ;
65use gix_transport:: client:: Capabilities ;
76
87#[ cfg( feature = "async-client" ) ]
@@ -67,6 +66,25 @@ impl Options {
6766 extra_refspecs,
6867 }
6968 }
69+
70+ fn push_prefix_arguments ( & self , arguments : & mut Vec < BString > ) {
71+ if !self . prefix_from_spec_as_filter_on_remote {
72+ return ;
73+ }
74+
75+ let mut seen = HashSet :: new ( ) ;
76+ for spec in & self . all_refspecs {
77+ let spec = spec. to_ref ( ) ;
78+ if seen. insert ( spec. instruction ( ) ) {
79+ let mut prefixes = Vec :: with_capacity ( 1 ) ;
80+ spec. expand_prefixes ( & mut prefixes) ;
81+ for mut prefix in prefixes {
82+ prefix. insert_str ( 0 , "ref-prefix " ) ;
83+ arguments. push ( prefix) ;
84+ }
85+ }
86+ }
87+ }
7088}
7189
7290impl RefMap {
@@ -82,12 +100,7 @@ impl RefMap {
82100 transport : & mut T ,
83101 user_agent : ( & ' static str , Option < Cow < ' static , str > > ) ,
84102 trace_packetlines : bool ,
85- Options {
86- fetch_refspecs,
87- prefix_from_spec_as_filter_on_remote,
88- extra_refspecs,
89- all_refspecs,
90- } : Options ,
103+ options : Options ,
91104 ) -> Result < Self , Error >
92105 where
93106 T : Transport ,
@@ -100,20 +113,7 @@ impl RefMap {
100113 transport,
101114 & handshake. capabilities ,
102115 |_capabilities, arguments| {
103- if prefix_from_spec_as_filter_on_remote {
104- let mut seen = HashSet :: new ( ) ;
105- for spec in & all_refspecs {
106- let spec = spec. to_ref ( ) ;
107- if seen. insert ( spec. instruction ( ) ) {
108- let mut prefixes = Vec :: with_capacity ( 1 ) ;
109- spec. expand_prefixes ( & mut prefixes) ;
110- for mut prefix in prefixes {
111- prefix. insert_str ( 0 , "ref-prefix " ) ;
112- arguments. push ( prefix) ;
113- }
114- }
115- }
116- }
116+ options. push_prefix_arguments ( arguments) ;
117117 Ok ( crate :: ls_refs:: Action :: Continue )
118118 } ,
119119 & mut progress,
@@ -124,22 +124,17 @@ impl RefMap {
124124 }
125125 } ;
126126
127- Self :: from_refs (
128- remote_refs,
129- & handshake. capabilities ,
127+ Self :: from_refs ( remote_refs, & handshake. capabilities , options)
128+ }
129+
130+ fn from_refs ( remote_refs : Vec < Ref > , capabilities : & Capabilities , options : Options ) -> Result < RefMap , Error > {
131+ let Options {
130132 fetch_refspecs,
131- all_refspecs,
132133 extra_refspecs,
133- )
134- }
134+ all_refspecs,
135+ ..
136+ } = options;
135137
136- fn from_refs (
137- remote_refs : Vec < Ref > ,
138- capabilities : & Capabilities ,
139- fetch_refspecs : Vec < RefSpec > ,
140- all_refspecs : Vec < RefSpec > ,
141- extra_refspecs : Vec < RefSpec > ,
142- ) -> Result < Self , Error > {
143138 let num_explicit_specs = fetch_refspecs. len ( ) ;
144139 let group = gix_refspec:: MatchGroup :: from_fetch_specs ( all_refspecs. iter ( ) . map ( gix_refspec:: RefSpec :: to_ref) ) ;
145140 let null = gix_hash:: ObjectId :: null ( gix_hash:: Kind :: Sha1 ) ; // OK to hardcode Sha1, it's not supposed to match, ever.
0 commit comments