Skip to content

Commit 877f4d2

Browse files
committed
fix: don't unconditionally stuff fetch-specs if these are already present.
Previously, we'd always add 'default' refspecs, even though ref-specs might already have been present. Now we only do this if there were no refspecs prior, and that might still be more than Git does. I wonder where this requirement came from, except that it might help with tests.
1 parent 977b81b commit 877f4d2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

gix/src/clone/fetch/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ impl PrepareFetch {
105105
.unwrap_or_else(|| "origin".into()),
106106
};
107107

108-
let mut remote = repo
109-
.remote_at(self.url.clone())?
110-
.with_refspecs(
111-
Some(format!("+refs/heads/*:refs/remotes/{remote_name}/*").as_str()),
112-
remote::Direction::Fetch,
113-
)
114-
.expect("valid static spec");
108+
let mut remote = repo.remote_at(self.url.clone())?;
109+
if remote.fetch_specs.is_empty() {
110+
remote = remote
111+
.with_refspecs(
112+
Some(format!("+refs/heads/*:refs/remotes/{remote_name}/*").as_str()),
113+
remote::Direction::Fetch,
114+
)
115+
.expect("valid static spec");
116+
}
115117
let mut clone_fetch_tags = None;
116118
if let Some(f) = self.configure_remote.as_mut() {
117119
remote = f(remote).map_err(Error::RemoteConfiguration)?;

0 commit comments

Comments
 (0)