Skip to content

Commit 37a42bd

Browse files
committed
protocol: attach push_prefix_arguments() to LsRefsCommand
1 parent 0f58b01 commit 37a42bd

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

gix-protocol/src/fetch/refmap/init.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use std::{borrow::Cow, collections::HashSet};
1+
use std::borrow::Cow;
22

3-
use bstr::{BString, ByteSlice, ByteVec};
3+
use bstr::{BString, ByteSlice};
44
use gix_features::progress::Progress;
55
use gix_transport::client::Capabilities;
66

@@ -79,7 +79,7 @@ impl RefMap {
7979
let all_refspecs = context.aggregate_refspecs();
8080
let mut refs_cmd = crate::LsRefsCommand::new(capabilities, user_agent);
8181
if prefix_from_spec_as_filter_on_remote {
82-
push_prefix_arguments(&all_refspecs, refs_cmd.arguments());
82+
refs_cmd.push_prefix_arguments(&all_refspecs);
8383
}
8484

8585
let remote_refs = refs_cmd.invoke(transport, &mut progress, trace_packetlines).await?;
@@ -154,18 +154,3 @@ impl RefMap {
154154
})
155155
}
156156
}
157-
158-
fn push_prefix_arguments(all_refspecs: &[gix_refspec::RefSpec], arguments: &mut Vec<BString>) {
159-
let mut seen = HashSet::new();
160-
for spec in all_refspecs {
161-
let spec = spec.to_ref();
162-
if seen.insert(spec.instruction()) {
163-
let mut prefixes = Vec::with_capacity(1);
164-
spec.expand_prefixes(&mut prefixes);
165-
for mut prefix in prefixes {
166-
prefix.insert_str(0, "ref-prefix ");
167-
arguments.push(prefix);
168-
}
169-
}
170-
}
171-
}

gix-protocol/src/ls_refs.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ pub use error::Error;
3131

3232
#[cfg(any(feature = "blocking-client", feature = "async-client"))]
3333
pub(crate) mod function {
34-
use std::borrow::Cow;
34+
use std::{borrow::Cow, collections::HashSet};
3535

36-
use bstr::BString;
36+
use bstr::{BString, ByteVec};
3737
use gix_features::progress::Progress;
3838
use gix_transport::client::Capabilities;
3939
use maybe_async::maybe_async;
@@ -115,9 +115,19 @@ pub(crate) mod function {
115115
Ok(from_v2_refs(&mut remote_refs).await?)
116116
}
117117

118-
/// The arguments that will be sent to the server as part of the ls-refs command.
119-
pub fn arguments(&mut self) -> &mut Vec<BString> {
120-
&mut self.arguments
118+
pub(crate) fn push_prefix_arguments(&mut self, all_refspecs: &[gix_refspec::RefSpec]) {
119+
let mut seen = HashSet::new();
120+
for spec in all_refspecs {
121+
let spec = spec.to_ref();
122+
if seen.insert(spec.instruction()) {
123+
let mut prefixes = Vec::with_capacity(1);
124+
spec.expand_prefixes(&mut prefixes);
125+
for mut prefix in prefixes {
126+
prefix.insert_str(0, "ref-prefix ");
127+
self.arguments.push(prefix);
128+
}
129+
}
130+
}
121131
}
122132
}
123133
}

0 commit comments

Comments
 (0)