Fixes #1099
Unified · Split
| @@ -291,7 +291,12 @@ pub mod decode { · 290 unmodified lines | |||
| 291 | 291 | ||
| 292 | impl std::fmt::Display for Error { | 292 | impl std::fmt::Display for Error { |
| 293 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 293 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 294 | self.inner.fmt(f) | 294 | write!(f, "object parsing failed at `{}`", bstr::BStr::new(&self.remaining))?; |
| 295 | if self.inner.context().next().is_some() { | ||
| 296 | writeln!(f)?; | ||
| 297 | self.inner.fmt(f)?; | ||
| 298 | } | ||
| 299 | Ok(()) | ||
| 295 | } | 300 | } |
| 296 | } | 301 | } |
| 297 | 302 | ||
| @@ -169,7 +169,7 @@ fn invalid() { · 168 unmodified lines | |||
| 169 | assert_eq!( | 169 | assert_eq!( |
| 170 | CommitRef::from_bytes(partial_commit).unwrap_err().to_string(), | 170 | CommitRef::from_bytes(partial_commit).unwrap_err().to_string(), |
| 171 | if cfg!(feature = "verbose-object-parsing-errors") { | 171 | if cfg!(feature = "verbose-object-parsing-errors") { |
| 172 | "expected `<timestamp>`, `<name> <<email>> <timestamp> <+|-><HHMM>`, `author <signature>`" | 172 | "object parsing failed at `1`\nexpected `<timestamp>`, `<name> <<email>> <timestamp> <+|-><HHMM>`, `author <signature>`" |
| 173 | } else { | 173 | } else { |
| 174 | "object parsing failed" | 174 | "object parsing failed" |
| 175 | } | 175 | } |
| @@ -123,7 +123,7 @@ fn invalid() { · 122 unmodified lines | |||
| 123 | assert_eq!( | 123 | assert_eq!( |
| 124 | TagRef::from_bytes(partial_tag).unwrap_err().to_string(), | 124 | TagRef::from_bytes(partial_tag).unwrap_err().to_string(), |
| 125 | if cfg!(feature = "verbose-object-parsing-errors") { | 125 | if cfg!(feature = "verbose-object-parsing-errors") { |
| 126 | "" | 126 | "object parsing failed at `tagger Sebasti`" |
| 127 | } else { | 127 | } else { |
| 128 | "object parsing failed" | 128 | "object parsing failed" |
| 129 | } | 129 | } |
| @@ -111,14 +111,12 @@ mod from_bytes { · 110 unmodified lines | |||
| 111 | fn invalid() { | 111 | fn invalid() { |
| 112 | let fixture = fixture_name("tree", "definitely-special.tree"); | 112 | let fixture = fixture_name("tree", "definitely-special.tree"); |
| 113 | let partial_tree = &fixture[..fixture.len() / 2]; | 113 | let partial_tree = &fixture[..fixture.len() / 2]; |
| 114 | assert_eq!( | 114 | let err = TreeRef::from_bytes(partial_tree).unwrap_err().to_string(); |
| 115 | TreeRef::from_bytes(partial_tree).unwrap_err().to_string(), | 115 | if cfg!(feature = "verbose-object-parsing-errors") { |
| 116 | if cfg!(feature = "verbose-object-parsing-errors") { | 116 | assert!(err.starts_with("object parsing failed at `100644"), "{err}"); |
| 117 | "" | 117 | } else { |
| 118 | } else { | 118 | assert_eq!(err, "object parsing failed"); |
| 119 | "object parsing failed" | 119 | } |
| 120 | } | ||
| 121 | ); | ||
| 122 | assert_eq!( | 120 | assert_eq!( |
| 123 | TreeRefIter::from_bytes(partial_tree).take_while(Result::is_ok).count(), | 121 | TreeRefIter::from_bytes(partial_tree).take_while(Result::is_ok).count(), |
| 124 | 9, | 122 | 9, |