File tree Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Expand file tree Collapse file tree 2 files changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,8 @@ class GitMergeTooManyBases extends GitException {}
155155
156156class GitMergeOnHashNotAllowed extends GitException {}
157157
158+ class GitMergeNoCommonAncestor extends GitException {}
159+
158160class GitNotImplemented extends GitException {}
159161
160162class GitRepoExists implements GitException {}
Original file line number Diff line number Diff line change @@ -36,25 +36,26 @@ extension Merge on GitRepository {
3636 if (bases.length > 1 ) {
3737 throw GitMergeTooManyBases ();
3838 }
39- if (bases.isNotEmpty) {
40- var baseHash = bases.first.hash;
39+ if (bases.isEmpty) {
40+ throw GitMergeNoCommonAncestor ();
41+ }
42+ var baseHash = bases.first.hash;
4143
42- // up to date
43- if (baseHash == commitB.hash) {
44- return ;
45- }
44+ // up to date
45+ if (baseHash == commitB.hash) {
46+ return ;
47+ }
4648
47- // fastforward
48- if (baseHash == headCommit.hash) {
49- var branchNameRef = headRef.target;
50- assert (branchNameRef.isBranch ());
49+ // fastforward
50+ if (baseHash == headCommit.hash) {
51+ var branchNameRef = headRef.target;
52+ assert (branchNameRef.isBranch ());
5153
52- var newRef = HashReference (branchNameRef, commitB.hash);
53- refStorage.saveRef (newRef);
54+ var newRef = HashReference (branchNameRef, commitB.hash);
55+ refStorage.saveRef (newRef);
5456
55- checkout ('.' );
56- return ;
57- }
57+ checkout ('.' );
58+ return ;
5859 }
5960
6061 var baseTree = objStorage.readTree (bases.first.treeHash);
You can’t perform that action at this time.
0 commit comments