File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -120,18 +120,35 @@ - (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError **)er
120
120
return NO ;
121
121
}
122
122
123
+ GTAnnotatedCommit *remoteAnnotatedCommit = [GTAnnotatedCommit annotatedCommitFromReference: branch.reference error: error];
124
+ if (!remoteAnnotatedCommit) {
125
+ return NO ;
126
+ }
127
+
123
128
GTMergeAnalysis analysis = GTMergeAnalysisNone;
124
- BOOL success = [self analyzeMerge: &analysis fromBranch: branch error: error];
129
+ GTMergePreference preference = GTMergePreferenceNone;
130
+ BOOL success = [self analyzeMerge: &analysis preference: &preference fromAnnotatedCommits: @[remoteAnnotatedCommit] error: error];
125
131
if (!success) {
126
132
return NO ;
127
133
}
128
134
129
135
if (analysis & GTMergeAnalysisUpToDate) {
130
136
// Nothing to do
131
137
return YES ;
132
- } else if (analysis & GTMergeAnalysisFastForward ||
133
- analysis & GTMergeAnalysisUnborn) {
138
+ } else if (analysis & GTMergeAnalysisFastForward && preference == GTMergePreferenceNoFastForward) {
134
139
// Fast-forward branch
140
+ if (error != NULL ) {
141
+ *error = [NSError git_errorFor: GIT_ERROR description: @" Normal merge not possible for branch '%@ '" , branch.name];
142
+ }
143
+ return NO ;
144
+ } else if (analysis & GTMergeAnalysisNormal && preference == GTMergePreferenceFastForwardOnly) {
145
+ if (error != NULL ) {
146
+ *error = [NSError git_errorFor: GIT_ERROR description: @" Fast-forward not possible for branch '%@ '" , branch.name];
147
+ }
148
+ return NO ;
149
+ }
150
+
151
+ if (analysis & GTMergeAnalysisFastForward) {
135
152
NSString *message = [NSString stringWithFormat: @" merge %@ : Fast-forward" , branch.name];
136
153
GTReference *reference = [localBranch.reference referenceByUpdatingTarget: remoteCommit.SHA message: message error: error];
137
154
BOOL checkoutSuccess = [self checkoutReference: reference options: [GTCheckoutOptions checkoutOptionsWithStrategy: GTCheckoutStrategyForce] error: error];
You can’t perform that action at this time.
0 commit comments