File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,16 @@ pub fn cherry_pick(
51
51
head_id : git2:: Oid ,
52
52
cherry_id : git2:: Oid ,
53
53
) -> Result < git2:: Oid , git2:: Error > {
54
- let base_id = repo. merge_base ( head_id, cherry_id) . unwrap_or ( cherry_id) ;
54
+ let cherry_commit = repo. find_commit ( cherry_id) ?;
55
+ let base_id = match cherry_commit. parent_count ( ) {
56
+ 0 => cherry_id,
57
+ 1 => cherry_commit. parent_id ( 0 ) ?,
58
+ _ => cherry_commit
59
+ . parent_ids ( )
60
+ . find ( |id| * id == head_id)
61
+ . map ( Result :: Ok )
62
+ . unwrap_or_else ( || cherry_commit. parent_id ( 0 ) ) ?,
63
+ } ;
55
64
if base_id == head_id {
56
65
// Already on top of the intended base
57
66
return Ok ( cherry_id) ;
@@ -60,7 +69,6 @@ pub fn cherry_pick(
60
69
let base_ann_commit = repo. find_annotated_commit ( base_id) ?;
61
70
let head_ann_commit = repo. find_annotated_commit ( head_id) ?;
62
71
let cherry_ann_commit = repo. find_annotated_commit ( cherry_id) ?;
63
- let cherry_commit = repo. find_commit ( cherry_id) ?;
64
72
let mut rebase = repo. rebase (
65
73
Some ( & cherry_ann_commit) ,
66
74
Some ( & base_ann_commit) ,
You can’t perform that action at this time.
0 commit comments