@@ -49,8 +49,8 @@ struct Args {
4949
5050fn run ( args : & Args ) -> Result < ( ) , Error > {
5151 let path = args. flag_git_dir . as_ref ( ) . map ( |s| & s[ ..] ) . unwrap_or ( "." ) ;
52- let repo = try! ( Repository :: open ( path) ) ;
53- let mut revwalk = try! ( repo. revwalk ( ) ) ;
52+ let repo = Repository :: open ( path) ? ;
53+ let mut revwalk = repo. revwalk ( ) ? ;
5454
5555 // Prepare the revwalk based on CLI parameters
5656 let base = if args. flag_reverse { git2:: Sort :: REVERSE } else { git2:: Sort :: NONE } ;
@@ -63,27 +63,27 @@ fn run(args: &Args) -> Result<(), Error> {
6363 } ) ;
6464 for commit in & args. arg_commit {
6565 if commit. starts_with ( '^' ) {
66- let obj = try! ( repo. revparse_single ( & commit[ 1 ..] ) ) ;
67- try! ( revwalk. hide ( obj. id ( ) ) ) ;
66+ let obj = repo. revparse_single ( & commit[ 1 ..] ) ? ;
67+ revwalk. hide ( obj. id ( ) ) ? ;
6868 continue
6969 }
70- let revspec = try! ( repo. revparse ( commit) ) ;
70+ let revspec = repo. revparse ( commit) ? ;
7171 if revspec. mode ( ) . contains ( git2:: RevparseMode :: SINGLE ) {
72- try! ( revwalk. push ( revspec. from ( ) . unwrap ( ) . id ( ) ) ) ;
72+ revwalk. push ( revspec. from ( ) . unwrap ( ) . id ( ) ) ? ;
7373 } else {
7474 let from = revspec. from ( ) . unwrap ( ) . id ( ) ;
7575 let to = revspec. to ( ) . unwrap ( ) . id ( ) ;
76- try! ( revwalk. push ( to) ) ;
76+ revwalk. push ( to) ? ;
7777 if revspec. mode ( ) . contains ( git2:: RevparseMode :: MERGE_BASE ) {
78- let base = try! ( repo. merge_base ( from, to) ) ;
79- let o = try! ( repo. find_object ( base, Some ( ObjectType :: Commit ) ) ) ;
80- try! ( revwalk. push ( o. id ( ) ) ) ;
78+ let base = repo. merge_base ( from, to) ? ;
79+ let o = repo. find_object ( base, Some ( ObjectType :: Commit ) ) ? ;
80+ revwalk. push ( o. id ( ) ) ? ;
8181 }
82- try! ( revwalk. hide ( from) ) ;
82+ revwalk. hide ( from) ? ;
8383 }
8484 }
8585 if args. arg_commit . is_empty ( ) {
86- try! ( revwalk. push_head ( ) ) ;
86+ revwalk. push_head ( ) ? ;
8787 }
8888
8989 // Prepare our diff options and pathspec matcher
@@ -92,7 +92,7 @@ fn run(args: &Args) -> Result<(), Error> {
9292 diffopts. pathspec ( spec) ;
9393 diffopts2. pathspec ( spec) ;
9494 }
95- let ps = try! ( Pathspec :: new ( args. arg_spec . iter ( ) ) ) ;
95+ let ps = Pathspec :: new ( args. arg_spec . iter ( ) ) ? ;
9696
9797 // Filter our revwalk based on the CLI parameters
9898 macro_rules! filter_try {
@@ -130,26 +130,26 @@ fn run(args: &Args) -> Result<(), Error> {
130130
131131 // print!
132132 for commit in revwalk {
133- let commit = try! ( commit) ;
133+ let commit = commit? ;
134134 print_commit ( & commit) ;
135135 if !args. flag_patch || commit. parents ( ) . len ( ) > 1 { continue }
136136 let a = if commit. parents ( ) . len ( ) == 1 {
137- let parent = try! ( commit. parent ( 0 ) ) ;
138- Some ( try! ( parent. tree ( ) ) )
137+ let parent = commit. parent ( 0 ) ? ;
138+ Some ( parent. tree ( ) ? )
139139 } else {
140140 None
141141 } ;
142- let b = try! ( commit. tree ( ) ) ;
143- let diff = try! ( repo. diff_tree_to_tree ( a. as_ref ( ) , Some ( & b) ,
144- Some ( & mut diffopts2) ) ) ;
145- try! ( diff. print ( DiffFormat :: Patch , |_delta, _hunk, line| {
142+ let b = commit. tree ( ) ? ;
143+ let diff = repo. diff_tree_to_tree ( a. as_ref ( ) , Some ( & b) ,
144+ Some ( & mut diffopts2) ) ? ;
145+ diff. print ( DiffFormat :: Patch , |_delta, _hunk, line| {
146146 match line. origin ( ) {
147147 ' ' | '+' | '-' => print ! ( "{}" , line. origin( ) ) ,
148148 _ => { }
149149 }
150150 print ! ( "{}" , str :: from_utf8( line. content( ) ) . unwrap( ) ) ;
151151 true
152- } ) ) ;
152+ } ) ? ;
153153 }
154154
155155 Ok ( ( ) )
@@ -181,18 +181,18 @@ fn print_commit(commit: &Commit) {
181181 for id in commit. parent_ids ( ) {
182182 print ! ( " {:.8}" , id) ;
183183 }
184- println ! ( "" ) ;
184+ println ! ( ) ;
185185 }
186186
187187 let author = commit. author ( ) ;
188188 println ! ( "Author: {}" , author) ;
189189 print_time ( & author. when ( ) , "Date: " ) ;
190- println ! ( "" ) ;
190+ println ! ( ) ;
191191
192192 for line in String :: from_utf8_lossy ( commit. message_bytes ( ) ) . lines ( ) {
193193 println ! ( " {}" , line) ;
194194 }
195- println ! ( "" ) ;
195+ println ! ( ) ;
196196}
197197
198198fn print_time ( time : & Time , prefix : & str ) {
@@ -212,9 +212,9 @@ fn print_time(time: &Time, prefix: &str) {
212212
213213fn match_with_parent ( repo : & Repository , commit : & Commit , parent : & Commit ,
214214 opts : & mut DiffOptions ) -> Result < bool , Error > {
215- let a = try! ( parent. tree ( ) ) ;
216- let b = try! ( commit. tree ( ) ) ;
217- let diff = try! ( repo. diff_tree_to_tree ( Some ( & a) , Some ( & b) , Some ( opts) ) ) ;
215+ let a = parent. tree ( ) ? ;
216+ let b = commit. tree ( ) ? ;
217+ let diff = repo. diff_tree_to_tree ( Some ( & a) , Some ( & b) , Some ( opts) ) ? ;
218218 Ok ( diff. deltas ( ) . len ( ) > 0 )
219219}
220220
0 commit comments