@@ -32,6 +32,9 @@ pub enum Error {
3232/// For use in [`RefMap::new()`].
3333#[ derive( Debug , Clone ) ]
3434pub struct Options {
35+ /// All explicit refspecs to identify references on the remote that you are interested in.
36+ /// Note that these are copied to [`RefMap::refspecs`] for convenience, as `RefMap::mappings` refer to them by index.
37+ pub fetch_refspecs : Vec < gix_refspec:: RefSpec > ,
3538 /// Use a two-component prefix derived from the ref-spec's source, like `refs/heads/` to let the server pre-filter refs
3639 /// with great potential for savings in traffic and local CPU time. Defaults to `true`.
3740 pub prefix_from_spec_as_filter_on_remote : bool ,
@@ -41,9 +44,11 @@ pub struct Options {
4144 pub extra_refspecs : Vec < gix_refspec:: RefSpec > ,
4245}
4346
44- impl Default for Options {
45- fn default ( ) -> Self {
47+ impl Options {
48+ /// Create options to fetch the given `fetch_refspecs`.
49+ pub fn fetch ( fetch_refspecs : Vec < gix_refspec:: RefSpec > ) -> Self {
4650 Options {
51+ fetch_refspecs,
4752 prefix_from_spec_as_filter_on_remote : true ,
4853 extra_refspecs : Vec :: new ( ) ,
4954 }
@@ -58,18 +63,16 @@ impl RefMap {
5863 /// and [options](Options) are used to further configure the call.
5964 ///
6065 /// * `progress` is used if `ls-refs` is invoked on the remote. Always the case when V2 is used.
61- /// * `fetch_refspecs` are all explicit refspecs to identify references on the remote that you are interested in.
62- /// Note that these are copied to [`RefMap::refspecs`] for convenience, as `RefMap::mappings` refer to them by index.
6366 #[ allow( clippy:: result_large_err) ]
6467 #[ maybe_async:: maybe_async]
6568 pub async fn new < T > (
6669 mut progress : impl Progress ,
67- fetch_refspecs : & [ gix_refspec:: RefSpec ] ,
6870 handshake : & mut Outcome ,
6971 transport : & mut T ,
7072 user_agent : ( & ' static str , Option < Cow < ' static , str > > ) ,
7173 trace_packetlines : bool ,
7274 Options {
75+ fetch_refspecs,
7376 prefix_from_spec_as_filter_on_remote,
7477 extra_refspecs,
7578 } : Options ,
@@ -126,7 +129,7 @@ impl RefMap {
126129 fn from_refs (
127130 remote_refs : Vec < Ref > ,
128131 capabilities : & Capabilities ,
129- fetch_refspecs : & [ RefSpec ] ,
132+ fetch_refspecs : Vec < RefSpec > ,
130133 all_refspecs : Vec < RefSpec > ,
131134 extra_refspecs : Vec < RefSpec > ,
132135 ) -> Result < Self , Error > {
@@ -182,7 +185,7 @@ impl RefMap {
182185
183186 Ok ( Self {
184187 mappings,
185- refspecs : fetch_refspecs. to_vec ( ) ,
188+ refspecs : fetch_refspecs,
186189 extra_refspecs,
187190 fixes,
188191 remote_refs,
0 commit comments