@@ -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 }
@@ -55,18 +60,16 @@ impl RefMap {
5560 /// for _fetching_.
5661 ///
5762 /// * `progress` is used if `ls-refs` is invoked on the remote. Always the case when V2 is used.
58- /// * `fetch_refspecs` are all explicit refspecs to identify references on the remote that you are interested in.
59- /// Note that these are copied to [`RefMap::refspecs`] for convenience, as `RefMap::mappings` refer to them by index.
6063 #[ allow( clippy:: result_large_err) ]
6164 #[ maybe_async:: maybe_async]
6265 pub async fn new < T > (
6366 mut progress : impl Progress ,
64- fetch_refspecs : & [ gix_refspec:: RefSpec ] ,
6567 handshake : & mut Outcome ,
6668 transport : & mut T ,
6769 user_agent : ( & ' static str , Option < Cow < ' static , str > > ) ,
6870 trace_packetlines : bool ,
6971 Options {
72+ fetch_refspecs,
7073 prefix_from_spec_as_filter_on_remote,
7174 extra_refspecs,
7275 } : Options ,
@@ -123,7 +126,7 @@ impl RefMap {
123126 fn from_refs (
124127 remote_refs : Vec < Ref > ,
125128 capabilities : & Capabilities ,
126- fetch_refspecs : & [ RefSpec ] ,
129+ fetch_refspecs : Vec < RefSpec > ,
127130 all_refspecs : Vec < RefSpec > ,
128131 extra_refspecs : Vec < RefSpec > ,
129132 ) -> Result < Self , Error > {
@@ -179,7 +182,7 @@ impl RefMap {
179182
180183 Ok ( Self {
181184 mappings,
182- refspecs : fetch_refspecs. to_vec ( ) ,
185+ refspecs : fetch_refspecs,
183186 extra_refspecs,
184187 fixes,
185188 remote_refs,
0 commit comments