History

address auto-review

The new preflight `ref_map_by_ref()` call will implicitly add the tag refspec `refs/tags/*:refs/tags/*` based on the remote’s current `fetch_tags` setting, which can cause `ls-refs` to enumerate *all* tags just to resolve a single `ref_name`. This defeats the shallow single-ref optimization on repos with many tags. Consider temporarily setting `remote.fetch_tags` to `Tags::None` around this lookup (similar to the HEAD-lookup path below) so prefix filtering only requests the DWIM-expanded candidates for the requested name, rather than all tags.

GPT 5.5 committed 5 months ago

Commit 0c1645a1 parent 7734fb01 file · +3 −0Browse files

Unified · Split

gix/src/clone/fetch/mod.rs+3−0
@@ -116,6 +116,7 @@ impl PrepareFetch { · 115 unmodified lines
116116 let target_ref = if use_single_branch_for_shallow {
117117 // Determine target branch from user-specified ref_name or default branch
118118 if let Some(ref_name) = &self.ref_name {
119+ let prev_tags = std::mem::replace(&mut remote.fetch_tags, remote::fetch::Tags::None);
119120 let mut connection = remote.connect(remote::Direction::Fetch).await?;
120121 if let Some(f) = self.configure_connection.as_mut() {
121122 f(&mut connection).map_err(Error::RemoteConnection)?;
@@ -134,6 +135,8 @@ impl PrepareFetch { · 12 unmodified lines
134135 )
135136 .await?;
136137 let (_target, full_ref_name) = util::find_custom_refname(&refmap, ref_name)?;
138+ drop(connection);
139+ remote.fetch_tags = prev_tags;
137140 Some(full_ref_name.try_into()?)
138141 } else {
139142 // For shallow clones without a specified ref, we need to determine the ref to clone.