@@ -34,23 +34,37 @@ pub enum Error {
3434pub struct Options {
3535 /// All explicit refspecs to identify references on the remote that you are interested in.
3636 /// 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 > ,
37+ fetch_refspecs : Vec < gix_refspec:: RefSpec > ,
3838 /// Use a two-component prefix derived from the ref-spec's source, like `refs/heads/` to let the server pre-filter refs
3939 /// with great potential for savings in traffic and local CPU time. Defaults to `true`.
40- pub prefix_from_spec_as_filter_on_remote : bool ,
40+ prefix_from_spec_as_filter_on_remote : bool ,
4141 /// A list of refspecs to use as implicit refspecs which won't be saved or otherwise be part of the remote in question.
4242 ///
4343 /// This is useful for handling `remote.<name>.tagOpt` for example.
44- pub extra_refspecs : Vec < gix_refspec:: RefSpec > ,
44+ extra_refspecs : Vec < gix_refspec:: RefSpec > ,
45+ all_refspecs : Vec < gix_refspec:: RefSpec > ,
4546}
4647
4748impl Options {
4849 /// Create options to fetch the given `fetch_refspecs`.
4950 pub fn fetch ( fetch_refspecs : Vec < gix_refspec:: RefSpec > ) -> Self {
50- Options {
51- fetch_refspecs,
52- prefix_from_spec_as_filter_on_remote : true ,
53- extra_refspecs : Vec :: new ( ) ,
51+ Self :: new ( fetch_refspecs, true , Vec :: new ( ) )
52+ }
53+
54+ /// Specify all options for fetching.
55+ pub fn new (
56+ fetch_refspecs : Vec < gix_refspec:: RefSpec > ,
57+ prefix_from_spec_as_filter_on_remote : bool ,
58+ extra_refspecs : Vec < gix_refspec:: RefSpec > ,
59+ ) -> Self {
60+ let mut all_refspecs = fetch_refspecs. clone ( ) ;
61+ all_refspecs. extend ( extra_refspecs. iter ( ) . cloned ( ) ) ;
62+
63+ Self {
64+ all_refspecs,
65+ fetch_refspecs : fetch_refspecs. clone ( ) ,
66+ prefix_from_spec_as_filter_on_remote,
67+ extra_refspecs,
5468 }
5569 }
5670}
@@ -75,17 +89,13 @@ impl RefMap {
7589 fetch_refspecs,
7690 prefix_from_spec_as_filter_on_remote,
7791 extra_refspecs,
92+ all_refspecs,
7893 } : Options ,
7994 ) -> Result < Self , Error >
8095 where
8196 T : Transport ,
8297 {
8398 let _span = gix_trace:: coarse!( "gix_protocol::fetch::RefMap::new()" ) ;
84- let all_refspecs = {
85- let mut s: Vec < _ > = fetch_refspecs. to_vec ( ) ;
86- s. extend ( extra_refspecs. clone ( ) ) ;
87- s
88- } ;
8999 let remote_refs = match handshake. refs . take ( ) {
90100 Some ( refs) => refs,
91101 None => {
0 commit comments