Unified · Split
| @@ -59,24 +59,6 @@ fn validated_name(name: Cow<'_, BStr>) -> Result<Cow<'_, BStr>, Error> { · 58 unmodified lines | ||
| 59 | 59 | .ok_or(Error::InvalidName) |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | −#[cfg(test)] | |
| 63 | −mod tests { | |
| 64 | − use super::*; | |
| 65 | − | |
| 66 | − #[test] | |
| 67 | − fn empty_header_names_are_legal() { | |
| 68 | − assert!(Header::new("", None).is_ok(), "yes, git allows this, so do we"); | |
| 69 | − } | |
| 70 | − | |
| 71 | − #[test] | |
| 72 | − fn empty_header_sub_names_are_legal() { | |
| 73 | − assert!( | |
| 74 | − Header::new("remote", Some(Cow::Borrowed("".into()))).is_ok(), | |
| 75 | − "yes, git allows this, so do we" | |
| 76 | − ); | |
| 77 | − } | |
| 78 | −} | |
| 79 | − | |
| 80 | 62 | impl Header<'_> { |
| 81 | 63 | ///Return true if this is a header like `[legacy.subsection]`, or false otherwise. |
| 82 | 64 | pub fn is_legacy(&self) -> bool { |
| @@ -178,3 +160,21 @@ impl<'a> From<Header<'a>> for Event<'a> { · 95 unmodified lines | ||
| 178 | 160 | Event::SectionHeader(header) |
| 179 | 161 | } |
| 180 | 162 | } |
| 163 | + | |
| 164 | +#[cfg(test)] | |
| 165 | +mod tests { | |
| 166 | + use super::*; | |
| 167 | + | |
| 168 | + #[test] | |
| 169 | + fn empty_header_names_are_legal() { | |
| 170 | + assert!(Header::new("", None).is_ok(), "yes, git allows this, so do we"); | |
| 171 | + } | |
| 172 | + | |
| 173 | + #[test] | |
| 174 | + fn empty_header_sub_names_are_legal() { | |
| 175 | + assert!( | |
| 176 | + Header::new("remote", Some(Cow::Borrowed("".into()))).is_ok(), | |
| 177 | + "yes, git allows this, so do we" | |
| 178 | + ); | |
| 179 | + } | |
| 180 | +} | |
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | use gix_hash::ObjectId; |
| 2 | 2 | use gix_testtools::fixture_path_standalone; |
| 3 | −pub use gix_testtools::{fixture_path, scripted_fixture_read_only}; | |
| 4 | 3 | |
| 5 | 4 | pub fn hex_to_id(hex: &str) -> ObjectId { |
| 6 | 5 | ObjectId::from_hex(hex.as_bytes()).expect("40 bytes hex") |
| @@ -72,24 +72,6 @@ enum State<'a, T> { · 71 unmodified lines | ||
| 72 | 72 | #[allow(unsafe_code, clippy::non_send_fields_in_send_ty)] |
| 73 | 73 | unsafe impl<'a, T> Send for State<'a, T> where T: Send {} |
| 74 | 74 | |
| 75 | −#[cfg(test)] | |
| 76 | −mod tests { | |
| 77 | − use super::*; | |
| 78 | − fn receiver<T: Send>(_i: T) {} | |
| 79 | − | |
| 80 | − /// We want to declare items containing pointers of `StreamingPeekableIter` `Send` as well, so it must be `Send` itself. | |
| 81 | − #[test] | |
| 82 | − fn streaming_peekable_iter_is_send() { | |
| 83 | − receiver(StreamingPeekableIter::new(Vec::<u8>::new(), &[], false)); | |
| 84 | − } | |
| 85 | − | |
| 86 | − #[test] | |
| 87 | − fn state_is_send() { | |
| 88 | − let mut s = StreamingPeekableIter::new(Vec::<u8>::new(), &[], false); | |
| 89 | − receiver(State::Idle { parent: Some(&mut s) }); | |
| 90 | − } | |
| 91 | −} | |
| 92 | − | |
| 93 | 75 | impl<'a, T, F> WithSidebands<'a, T, F> |
| 94 | 76 | where |
| 95 | 77 | T: AsyncRead + Unpin, |
| @@ -381,3 +363,21 @@ where · 285 unmodified lines | ||
| 381 | 363 | Poll::Ready(Ok(nread)) |
| 382 | 364 | } |
| 383 | 365 | } |
| 366 | + | |
| 367 | +#[cfg(test)] | |
| 368 | +mod tests { | |
| 369 | + use super::*; | |
| 370 | + fn receiver<T: Send>(_i: T) {} | |
| 371 | + | |
| 372 | + /// We want to declare items containing pointers of `StreamingPeekableIter` `Send` as well, so it must be `Send` itself. | |
| 373 | + #[test] | |
| 374 | + fn streaming_peekable_iter_is_send() { | |
| 375 | + receiver(StreamingPeekableIter::new(Vec::<u8>::new(), &[], false)); | |
| 376 | + } | |
| 377 | + | |
| 378 | + #[test] | |
| 379 | + fn state_is_send() { | |
| 380 | + let mut s = StreamingPeekableIter::new(Vec::<u8>::new(), &[], false); | |
| 381 | + receiver(State::Idle { parent: Some(&mut s) }); | |
| 382 | + } | |
| 383 | +} | |
| @@ -317,7 +317,8 @@ mod v2 { · 316 unmodified lines | ||
| 317 | 317 | assert_eq!(bytes_read, 1643, "should be able to read the whole pack"); |
| 318 | 318 | assert_eq!(&buf[..4], b"PACK"); |
| 319 | 319 | assert_eq!( |
| 320 | − gix_hash::ObjectId::from(&buf[buf.len() - gix_hash::Kind::Sha1.len_in_bytes()..]).to_string(), | |
| 320 | + gix_hash::ObjectId::from_bytes_or_panic(&buf[buf.len() - gix_hash::Kind::Sha1.len_in_bytes()..]) | |
| 321 | + .to_string(), | |
| 321 | 322 | "f34c9be7e0c3ef2c3ed7c62cc7791dbf6dc5ec9a" |
| 322 | 323 | ); |
| 323 | 324 | Ok(()) |
| @@ -45,7 +45,7 @@ impl file::Store { · 44 unmodified lines | ||
| 45 | 45 | Error: From<E>, |
| 46 | 46 | { |
| 47 | 47 | self.find_one_with_verified_input(partial.try_into()?, None) |
| 48 | − .map(|r| r.map(|r| r.try_into().expect("only loose refs are found without pack"))) | |
| 48 | + .map(|r| r.map(Into::into)) | |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /// Similar to [`file::Store::find()`], but allows to pass a snapshotted packed buffer instead. |
| @@ -267,8 +267,7 @@ pub mod existing { · 215 unmodified lines | ||
| 267 | 267 | Name: TryInto<&'a PartialNameRef, Error = E>, |
| 268 | 268 | crate::name::Error: From<E>, |
| 269 | 269 | { |
| 270 | − self.find_existing_inner(partial, None) | |
| 271 | − .map(|r| r.try_into().expect("always loose without packed")) | |
| 270 | + self.find_existing_inner(partial, None).map(Into::into) | |
| 272 | 271 | } |
| 273 | 272 | |
| 274 | 273 | /// Similar to [`file::Store::find()`] but a non-existing ref is treated as error. |
| @@ -605,7 +605,7 @@ mod update { · 604 unmodified lines | ||
| 605 | 605 | let (mut mappings, specs) = mapping_from_spec("refs/heads/symbolic:refs/remotes/origin/new", &repo); |
| 606 | 606 | mappings.push(Mapping { |
| 607 | 607 | remote: Source::Ref(gix_protocol::handshake::Ref::Direct { |
| 608 | − full_ref_name: "refs/heads/main".try_into().unwrap(), | |
| 608 | + full_ref_name: "refs/heads/main".into(), | |
| 609 | 609 | object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"), |
| 610 | 610 | }), |
| 611 | 611 | local: Some("refs/heads/symbolic".into()), |
| @@ -728,7 +728,7 @@ mod update { · 116 unmodified lines | ||
| 728 | 728 | let (mut mappings, specs) = mapping_from_spec("HEAD:refs/remotes/origin/new-HEAD", &repo); |
| 729 | 729 | mappings.push(Mapping { |
| 730 | 730 | remote: Source::Ref(gix_protocol::handshake::Ref::Direct { |
| 731 | − full_ref_name: "refs/heads/main".try_into().unwrap(), | |
| 731 | + full_ref_name: "refs/heads/main".into(), | |
| 732 | 732 | object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"), |
| 733 | 733 | }), |
| 734 | 734 | local: Some("refs/remotes/origin/main".into()), |
| @@ -72,7 +72,7 @@ impl SchemePermission { · 71 unmodified lines | ||
| 72 | 72 | scheme |
| 73 | 73 | .to_str() |
| 74 | 74 | .ok() |
| 75 | − .and_then(|scheme| gix_url::Scheme::try_from(scheme).ok().map(|scheme| (section, scheme))) | |
| 75 | + .map(|scheme| (section, gix_url::Scheme::from(scheme))) | |
| 76 | 76 | }) |
| 77 | 77 | }) { |
| 78 | 78 | if let Some(value) = section |