@@ -76,8 +76,9 @@ pub mod decode {
7676 use gix_object:: bstr:: { BStr , ByteSlice } ;
7777 use winnow:: {
7878 combinator:: { alt, eof, fail, opt, preceded, terminated} ,
79- error:: { AddContext , ParserError , StrContext } ,
79+ error:: { AddContext , ErrMode , ParserError , StrContext } ,
8080 prelude:: * ,
81+ stream:: Stream ,
8182 token:: { rest, take_while} ,
8283 } ;
8384
@@ -140,7 +141,7 @@ pub mod decode {
140141 let ( old, new, signature) = (
141142 terminated ( hex_hash, b" " ) . context ( StrContext :: Expected ( "<old-hexsha>" . into ( ) ) ) ,
142143 terminated ( hex_hash, b" " ) . context ( StrContext :: Expected ( "<new-hexsha>" . into ( ) ) ) ,
143- gix_actor :: signature:: decode . context ( StrContext :: Expected ( "<name> <<email>> <timestamp>" . into ( ) ) ) ,
144+ signature. context ( StrContext :: Expected ( "<name> <<email>> <timestamp>" . into ( ) ) ) ,
144145 )
145146 . context ( StrContext :: Expected (
146147 r"<old-hexsha> <new-hexsha> <name> <<email>> <timestamp> <tz>\t<message>" . into ( ) ,
@@ -161,7 +162,7 @@ pub mod decode {
161162 (
162163 terminated ( hex_hash, b" " ) . context ( StrContext :: Expected ( "<old-hexsha>" . into ( ) ) ) ,
163164 terminated ( hex_hash, b" " ) . context ( StrContext :: Expected ( "<new-hexsha>" . into ( ) ) ) ,
164- gix_actor :: signature:: decode . context ( StrContext :: Expected ( "<name> <<email>> <timestamp>" . into ( ) ) ) ,
165+ signature. context ( StrContext :: Expected ( "<name> <<email>> <timestamp>" . into ( ) ) ) ,
165166 )
166167 . context ( StrContext :: Expected (
167168 r"<old-hexsha> <new-hexsha> <name> <<email>> <timestamp> <tz>\t<message>" . into ( ) ,
@@ -188,6 +189,23 @@ pub mod decode {
188189 }
189190 }
190191
192+ fn signature < ' a , E : ParserError < & ' a [ u8 ] > + AddContext < & ' a [ u8 ] , StrContext > > (
193+ i : & mut & ' a [ u8 ] ,
194+ ) -> ModalResult < gix_actor:: SignatureRef < ' a > , E > {
195+ let start = i. checkpoint ( ) ;
196+ gix_actor:: signature:: decode ( i) . map_err ( |err| {
197+ ErrMode :: Cut ( E :: from_input ( i) . add_context ( i, & start, StrContext :: Label ( actor_error_label ( err) ) ) )
198+ } )
199+ }
200+
201+ fn actor_error_label ( err : gix_actor:: decode:: Error ) -> & ' static str {
202+ match err {
203+ gix_actor:: decode:: Error :: MissingClosingBracket => "Closing '>' not found" ,
204+ gix_actor:: decode:: Error :: MissingOpeningBracket => "Opening '<' not found" ,
205+ gix_actor:: decode:: Error :: DelimiterOverlap => "Skipped parts run into each other" ,
206+ }
207+ }
208+
191209 #[ cfg( test) ]
192210 mod test {
193211 use super :: * ;
0 commit comments