@@ -61,12 +61,10 @@ pub fn empty() -> Filter {
6161 to_filter ( Op :: Empty )
6262}
6363
64- pub fn squash ( ids : Option < ( & str , & str , & [ ( git2:: Oid , String ) ] ) > ) -> Filter {
65- if let Some ( ( author , email , ids) ) = ids {
64+ pub fn squash ( ids : Option < & [ ( git2:: Oid , String ) ] > ) -> Filter {
65+ if let Some ( ids) = ids {
6666 to_filter ( Op :: Squash ( Some (
67- ids. iter ( )
68- . map ( |( x, y) | ( * x, ( y. clone ( ) , author. to_string ( ) , email. to_string ( ) ) ) )
69- . collect ( ) ,
67+ ids. iter ( ) . map ( |( x, y) | ( * x, y. clone ( ) ) ) . collect ( ) ,
7068 ) ) )
7169 } else {
7270 to_filter ( Op :: Squash ( None ) )
@@ -97,7 +95,8 @@ enum Op {
9795 Empty ,
9896 Fold ,
9997 Paths ,
100- Squash ( Option < std:: collections:: HashMap < git2:: Oid , ( String , String , String ) > > ) ,
98+ Squash ( Option < std:: collections:: HashMap < git2:: Oid , String > > ) ,
99+ Author ( String , String ) ,
101100 Rev ( std:: collections:: HashMap < git2:: Oid , Filter > ) ,
102101 Linear ,
103102 Unsign ,
@@ -283,7 +282,7 @@ fn spec2(op: &Op) -> String {
283282 Op :: Squash ( Some ( hs) ) => {
284283 let mut v = hs
285284 . iter ( )
286- . map ( |( x, y) | format ! ( "{}:{}:{}:{} " , x, y. 0 , y . 1 , y . 2 ) )
285+ . map ( |( x, y) | format ! ( "{}:{}" , x, y) )
287286 . collect :: < Vec < String > > ( ) ;
288287 v. sort ( ) ;
289288 let s = v. join ( "," ) ;
@@ -297,6 +296,9 @@ fn spec2(op: &Op) -> String {
297296 Op :: File ( path) => format ! ( "::{}" , parse:: quote_if( & path. to_string_lossy( ) ) ) ,
298297 Op :: Prefix ( path) => format ! ( ":prefix={}" , parse:: quote_if( & path. to_string_lossy( ) ) ) ,
299298 Op :: Glob ( pattern) => format ! ( "::{}" , parse:: quote_if( pattern) ) ,
299+ Op :: Author ( author, email) => {
300+ format ! ( ":author={};{}" , parse:: quote( author) , parse:: quote( email) )
301+ }
300302 }
301303}
302304
@@ -403,6 +405,7 @@ fn apply_to_commit2(
403405 & [ ] ,
404406 & commit. tree ( ) ?,
405407 None ,
408+ None ,
406409 true ,
407410 ) )
408411 . transpose ( )
@@ -481,6 +484,7 @@ fn apply_to_commit2(
481484 transaction,
482485 filter,
483486 None ,
487+ None ,
484488 ) )
485489 . transpose ( ) ;
486490 }
@@ -502,7 +506,6 @@ fn apply_to_commit2(
502506 commit. tree ( ) ?,
503507 transaction,
504508 filter,
505- None ,
506509 ) )
507510 . transpose ( ) ;
508511 }
@@ -586,6 +589,7 @@ fn apply_to_commit2(
586589 transaction,
587590 filter,
588591 None ,
592+ None ,
589593 ) )
590594 . transpose ( ) ;
591595 }
@@ -662,6 +666,11 @@ fn apply_to_commit2(
662666
663667 let filtered_parent_ids = some_or ! ( filtered_parent_ids, { return Ok ( None ) } ) ;
664668
669+ let author = match to_op ( filter) {
670+ Op :: Author ( author, email) => Some ( ( author. clone ( ) , email. clone ( ) ) ) ,
671+ _ => None ,
672+ } ;
673+
665674 let message = match to_op ( filter) {
666675 Op :: Squash ( Some ( ids) ) => ids. get ( & commit. id ( ) ) . map ( |x| x. clone ( ) ) ,
667676 _ => None ,
@@ -673,6 +682,7 @@ fn apply_to_commit2(
673682 filtered_tree,
674683 transaction,
675684 filter,
685+ author,
676686 message,
677687 ) )
678688 . transpose ( )
@@ -698,6 +708,7 @@ fn apply2<'a>(
698708 Op :: Empty => return Ok ( tree:: empty ( repo) ) ,
699709 Op :: Fold => Ok ( tree) ,
700710 Op :: Squash ( None ) => Ok ( tree) ,
711+ Op :: Author ( _, _) => Ok ( tree) ,
701712 Op :: Squash ( Some ( _) ) => Err ( josh_error ( "not applicable to tree" ) ) ,
702713 Op :: Linear => Ok ( tree) ,
703714 Op :: Unsign => Ok ( tree) ,
0 commit comments