History

fix: `HEAD` may now return itself as prefix in `RefSpecRef::prefix()` and `expanded_prefix()`. (#450)

Previously, the expanded prefix would be a list of possibilities, even though it's such a common case that we really want to avoid spamming the remote about it when asking for HEAD during clone for instance.

Sebastian Thiel committed 4 years ago

Commit d53ddcd1 parent 9d0f31e2 files · +13 −6Browse files

Showing the changes to git-refspec/src (1 of 2 files). Show all

Unified · Split

git-refspec/src/spec.rs+3−0
@@ -134,6 +134,9 @@ impl<'a> RefSpecRef<'a> { · 133 unmodified lines
134 Operation::Fetch => self.source(),134 Operation::Fetch => self.source(),
135 Operation::Push => self.destination(),135 Operation::Push => self.destination(),
136 }?;136 }?;
137 if source == "HEAD" {
138 return source.into();
139 }
137 let suffix = source.strip_prefix(b"refs/")?;140 let suffix = source.strip_prefix(b"refs/")?;
138 let slash_pos = suffix.find_byte(b'/')?;141 let slash_pos = suffix.find_byte(b'/')?;
139 let prefix = source[..="refs/".len() + slash_pos].as_bstr();142 let prefix = source[..="refs/".len() + slash_pos].as_bstr();