@@ -51,29 +51,33 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
51
51
{
52
52
excludedBranches = CalculateWhenMultipleParents ( repository , currentCommit , ref currentBranch , excludedBranches ) ;
53
53
}
54
+
54
55
if ( excludedInheritBranches == null )
55
56
{
56
57
excludedInheritBranches = repository . Branches . Where ( b =>
57
58
{
58
59
var branchConfig = LookupBranchConfiguration ( config , b ) ;
59
- return branchConfig . Length == 1 && branchConfig [ 0 ] . Value . Increment == IncrementStrategy . Inherit ;
60
+
61
+ // NOTE: if length is 0 we couldn't find the configuration for the branch e.g. "origin/master"
62
+ // NOTE: if the length is greater than 1 we cannot decide which merge strategy to pick
63
+ return ( branchConfig . Length != 1 ) || ( branchConfig . Length == 1 && branchConfig [ 0 ] . Value . Increment == IncrementStrategy . Inherit ) ;
60
64
} ) . ToList ( ) ;
61
65
}
62
66
excludedBranches . ToList ( ) . ForEach ( excludedInheritBranches . Add ) ;
67
+ var branchesToEvaluate = repository . Branches . Except ( excludedInheritBranches ) . ToList ( ) ;
63
68
64
69
var branchPoint = currentBranch . FindCommitBranchWasBranchedFrom ( repository , excludedInheritBranches . ToArray ( ) ) ;
65
-
66
70
List < Branch > possibleParents ;
67
71
if ( branchPoint == null )
68
72
{
69
- possibleParents = currentCommit . GetBranchesContainingCommit ( repository , true ) . Except ( excludedInheritBranches ) . ToList ( ) ;
73
+ possibleParents = currentCommit . GetBranchesContainingCommit ( repository , branchesToEvaluate , true ) . ToList ( ) ;
70
74
}
71
75
else
72
76
{
73
- var branches = branchPoint . GetBranchesContainingCommit ( repository , true ) . Except ( excludedInheritBranches ) . ToList ( ) ;
77
+ var branches = branchPoint . GetBranchesContainingCommit ( repository , branchesToEvaluate , true ) . ToList ( ) ;
74
78
if ( branches . Count > 1 )
75
79
{
76
- var currentTipBranches = currentCommit . GetBranchesContainingCommit ( repository , true ) . Except ( excludedInheritBranches ) . ToList ( ) ;
80
+ var currentTipBranches = currentCommit . GetBranchesContainingCommit ( repository , branchesToEvaluate , true ) . ToList ( ) ;
77
81
possibleParents = branches . Except ( currentTipBranches ) . ToList ( ) ;
78
82
}
79
83
else
0 commit comments