@@ -49,8 +49,8 @@ struct Args {
49
49
50
50
fn run ( args : & Args ) -> Result < ( ) , Error > {
51
51
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 ( ) ? ;
54
54
55
55
// Prepare the revwalk based on CLI parameters
56
56
let base = if args. flag_reverse { git2:: Sort :: REVERSE } else { git2:: Sort :: NONE } ;
@@ -63,27 +63,27 @@ fn run(args: &Args) -> Result<(), Error> {
63
63
} ) ;
64
64
for commit in & args. arg_commit {
65
65
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 ( ) ) ? ;
68
68
continue
69
69
}
70
- let revspec = try! ( repo. revparse ( commit) ) ;
70
+ let revspec = repo. revparse ( commit) ? ;
71
71
if revspec. mode ( ) . contains ( git2:: RevparseMode :: SINGLE ) {
72
- try! ( revwalk. push ( revspec. from ( ) . unwrap ( ) . id ( ) ) ) ;
72
+ revwalk. push ( revspec. from ( ) . unwrap ( ) . id ( ) ) ? ;
73
73
} else {
74
74
let from = revspec. from ( ) . unwrap ( ) . id ( ) ;
75
75
let to = revspec. to ( ) . unwrap ( ) . id ( ) ;
76
- try! ( revwalk. push ( to) ) ;
76
+ revwalk. push ( to) ? ;
77
77
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 ( ) ) ? ;
81
81
}
82
- try! ( revwalk. hide ( from) ) ;
82
+ revwalk. hide ( from) ? ;
83
83
}
84
84
}
85
85
if args. arg_commit . is_empty ( ) {
86
- try! ( revwalk. push_head ( ) ) ;
86
+ revwalk. push_head ( ) ? ;
87
87
}
88
88
89
89
// Prepare our diff options and pathspec matcher
@@ -92,7 +92,7 @@ fn run(args: &Args) -> Result<(), Error> {
92
92
diffopts. pathspec ( spec) ;
93
93
diffopts2. pathspec ( spec) ;
94
94
}
95
- let ps = try! ( Pathspec :: new ( args. arg_spec . iter ( ) ) ) ;
95
+ let ps = Pathspec :: new ( args. arg_spec . iter ( ) ) ? ;
96
96
97
97
// Filter our revwalk based on the CLI parameters
98
98
macro_rules! filter_try {
@@ -130,26 +130,26 @@ fn run(args: &Args) -> Result<(), Error> {
130
130
131
131
// print!
132
132
for commit in revwalk {
133
- let commit = try! ( commit) ;
133
+ let commit = commit? ;
134
134
print_commit ( & commit) ;
135
135
if !args. flag_patch || commit. parents ( ) . len ( ) > 1 { continue }
136
136
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 ( ) ? )
139
139
} else {
140
140
None
141
141
} ;
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| {
146
146
match line. origin ( ) {
147
147
' ' | '+' | '-' => print ! ( "{}" , line. origin( ) ) ,
148
148
_ => { }
149
149
}
150
150
print ! ( "{}" , str :: from_utf8( line. content( ) ) . unwrap( ) ) ;
151
151
true
152
- } ) ) ;
152
+ } ) ? ;
153
153
}
154
154
155
155
Ok ( ( ) )
@@ -181,18 +181,18 @@ fn print_commit(commit: &Commit) {
181
181
for id in commit. parent_ids ( ) {
182
182
print ! ( " {:.8}" , id) ;
183
183
}
184
- println ! ( "" ) ;
184
+ println ! ( ) ;
185
185
}
186
186
187
187
let author = commit. author ( ) ;
188
188
println ! ( "Author: {}" , author) ;
189
189
print_time ( & author. when ( ) , "Date: " ) ;
190
- println ! ( "" ) ;
190
+ println ! ( ) ;
191
191
192
192
for line in String :: from_utf8_lossy ( commit. message_bytes ( ) ) . lines ( ) {
193
193
println ! ( " {}" , line) ;
194
194
}
195
- println ! ( "" ) ;
195
+ println ! ( ) ;
196
196
}
197
197
198
198
fn print_time ( time : & Time , prefix : & str ) {
@@ -212,9 +212,9 @@ fn print_time(time: &Time, prefix: &str) {
212
212
213
213
fn match_with_parent ( repo : & Repository , commit : & Commit , parent : & Commit ,
214
214
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) ) ? ;
218
218
Ok ( diff. deltas ( ) . len ( ) > 0 )
219
219
}
220
220
0 commit comments