File tree Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Expand file tree Collapse file tree 4 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -291,7 +291,12 @@ pub mod decode {
291291
292292 impl std:: fmt:: Display for Error {
293293 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 ( ( ) )
295300 }
296301 }
297302
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ fn invalid() {
169169 assert_eq ! (
170170 CommitRef :: from_bytes( partial_commit) . unwrap_err( ) . to_string( ) ,
171171 if cfg!( feature = "verbose-object-parsing-errors" ) {
172- "expected `<timestamp>`, `<name> <<email>> <timestamp> <+|-><HHMM>`, `author <signature>`"
172+ "object parsing failed at `1` \n expected `<timestamp>`, `<name> <<email>> <timestamp> <+|-><HHMM>`, `author <signature>`"
173173 } else {
174174 "object parsing failed"
175175 }
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ fn invalid() {
123123 assert_eq ! (
124124 TagRef :: from_bytes( partial_tag) . unwrap_err( ) . to_string( ) ,
125125 if cfg!( feature = "verbose-object-parsing-errors" ) {
126- ""
126+ "object parsing failed at `tagger Sebasti` "
127127 } else {
128128 "object parsing failed"
129129 }
Original file line number Diff line number Diff line change @@ -111,14 +111,12 @@ mod from_bytes {
111111 fn invalid ( ) {
112112 let fixture = fixture_name ( "tree" , "definitely-special.tree" ) ;
113113 let partial_tree = & fixture[ ..fixture. len ( ) / 2 ] ;
114- assert_eq ! (
115- TreeRef :: from_bytes( partial_tree) . unwrap_err( ) . to_string( ) ,
116- if cfg!( feature = "verbose-object-parsing-errors" ) {
117- ""
118- } else {
119- "object parsing failed"
120- }
121- ) ;
114+ let err = TreeRef :: from_bytes ( partial_tree) . unwrap_err ( ) . to_string ( ) ;
115+ if cfg ! ( feature = "verbose-object-parsing-errors" ) {
116+ assert ! ( err. starts_with( "object parsing failed at `100644" ) , "{err}" ) ;
117+ } else {
118+ assert_eq ! ( err, "object parsing failed" ) ;
119+ }
122120 assert_eq ! (
123121 TreeRefIter :: from_bytes( partial_tree) . take_while( Result :: is_ok) . count( ) ,
124122 9 ,
You can’t perform that action at this time.
0 commit comments