@@ -37,8 +37,7 @@ pub fn rebase_onto(onto: &str) -> Result<(), anyhow::Error> {
37
37
let repo = Repository :: open ( "." ) ?;
38
38
let onto = repo
39
39
. reference_to_annotated_commit (
40
- & repo
41
- . find_branch ( onto, git2:: BranchType :: Local )
40
+ repo. find_branch ( onto, git2:: BranchType :: Local )
42
41
. context ( "Chosing parent" ) ?
43
42
. get ( ) ,
44
43
)
@@ -50,7 +49,7 @@ pub fn rebase_onto(onto: &str) -> Result<(), anyhow::Error> {
50
49
. rebase ( Some ( & head) , None , Some ( & onto) , None )
51
50
. context ( "creating rebase" ) ?;
52
51
53
- if let Ok ( _ ) = do_rebase_inner ( & repo, rebase, None ) {
52
+ if do_rebase_inner ( & repo, rebase, None ) . is_ok ( ) {
54
53
rebase. finish ( None ) . context ( "finishing" ) ?;
55
54
}
56
55
@@ -169,7 +168,7 @@ fn do_rebase_inner(
169
168
fn commit_parent < ' a > ( commit : & ' a Commit ) -> Result < Commit < ' a > , anyhow:: Error > {
170
169
match commit. parents ( ) . next ( ) {
171
170
Some ( c) => Ok ( c) ,
172
- None => bail ! ( "Commit '{}' has no parents" , disp( & commit) ) ,
171
+ None => bail ! ( "Commit '{}' has no parents" , disp( commit) ) ,
173
172
}
174
173
}
175
174
@@ -198,12 +197,10 @@ fn get_upstream<'a>(
198
197
} )
199
198
. ok_or_else ( || anyhow ! ( "cannot find branch with name {:?}" , upstream_name) ) ?;
200
199
branch. into_reference ( ) . peel ( ObjectType :: Commit ) ?
200
+ } else if let Ok ( upstream) = head_branch. upstream ( ) {
201
+ upstream. into_reference ( ) . peel ( ObjectType :: Commit ) ?
201
202
} else {
202
- if let Ok ( upstream) = head_branch. upstream ( ) {
203
- upstream. into_reference ( ) . peel ( ObjectType :: Commit ) ?
204
- } else {
205
- return Ok ( None ) ;
206
- }
203
+ return Ok ( None ) ;
207
204
} ;
208
205
209
206
let mb = repo. merge_base (
@@ -282,19 +279,19 @@ fn select_commit_to_amend<'a>(
282
279
let commits = if let Some ( upstream) = upstream. as_ref ( ) {
283
280
let upstream_oid = upstream. id ( ) ;
284
281
walker
285
- . flat_map ( |r| r )
282
+ . flatten ( )
286
283
. take_while ( |rev| * rev != upstream_oid)
287
284
. take ( max_commits)
288
285
. map ( |rev| repo. find_commit ( rev) )
289
286
. collect :: < Result < Vec < _ > , _ > > ( ) ?
290
287
} else {
291
288
walker
292
- . flat_map ( |r| r )
289
+ . flatten ( )
293
290
. take ( max_commits)
294
291
. map ( |rev| repo. find_commit ( rev) )
295
292
. collect :: < Result < Vec < _ > , _ > > ( ) ?
296
293
} ;
297
- if commits. len ( ) == 0 {
294
+ if commits. is_empty ( ) {
298
295
bail ! (
299
296
"No commits between {} and {:?}" ,
300
297
format_ref( & repo. head( ) ?) ?,
@@ -330,7 +327,7 @@ fn select_commit_to_amend<'a>(
330
327
branches
331
328
. get ( & commit. id ( ) )
332
329
. map ( |n| format ! ( "({}) " , n) )
333
- . unwrap_or_else ( String :: new )
330
+ . unwrap_or_default ( )
334
331
} else {
335
332
String :: new ( )
336
333
} ;
0 commit comments