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.
Unified · Split
| @@ -116,6 +116,7 @@ impl PrepareFetch { · 115 unmodified lines | ||
| 116 | 116 | let target_ref = if use_single_branch_for_shallow { |
| 117 | 117 | // Determine target branch from user-specified ref_name or default branch |
| 118 | 118 | if let Some(ref_name) = &self.ref_name { |
| 119 | + let prev_tags = std::mem::replace(&mut remote.fetch_tags, remote::fetch::Tags::None); | |
| 119 | 120 | let mut connection = remote.connect(remote::Direction::Fetch).await?; |
| 120 | 121 | if let Some(f) = self.configure_connection.as_mut() { |
| 121 | 122 | f(&mut connection).map_err(Error::RemoteConnection)?; |
| @@ -134,6 +135,8 @@ impl PrepareFetch { · 12 unmodified lines | ||
| 134 | 135 | ) |
| 135 | 136 | .await?; |
| 136 | 137 | let (_target, full_ref_name) = util::find_custom_refname(&refmap, ref_name)?; |
| 138 | + drop(connection); | |
| 139 | + remote.fetch_tags = prev_tags; | |
| 137 | 140 | Some(full_ref_name.try_into()?) |
| 138 | 141 | } else { |
| 139 | 142 | // For shallow clones without a specified ref, we need to determine the ref to clone. |