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