@@ -136,65 +136,63 @@ - (BOOL)mergeBranchIntoCurrentBranch:(GTBranch *)branch withError:(NSError **)er
136
136
GTReference *reference = [localBranch.reference referenceByUpdatingTarget: remoteCommit.SHA message: message error: error];
137
137
BOOL checkoutSuccess = [self checkoutReference: reference options: [GTCheckoutOptions checkoutOptionsWithStrategy: GTCheckoutStrategyForce] error: error];
138
138
return checkoutSuccess;
139
- } else if (analysis & GTMergeAnalysisNormal) {
140
- // Do normal merge
141
- GTTree *localTree = localCommit.tree ;
142
- GTTree *remoteTree = remoteCommit.tree ;
143
-
144
- // TODO: Find common ancestor
145
- GTTree *ancestorTree = nil ;
146
-
147
- // Merge
148
- GTIndex *index = [localTree merge: remoteTree ancestor: ancestorTree error: error];
149
- if (!index) {
150
- return NO ;
151
- }
152
-
153
- // Check for conflict
154
- if (index.hasConflicts ) {
155
- NSMutableArray <NSString *>*files = [NSMutableArray array ];
156
- [index enumerateConflictedFilesWithError: error usingBlock: ^(GTIndexEntry * _Nonnull ancestor, GTIndexEntry * _Nonnull ours, GTIndexEntry * _Nonnull theirs, BOOL * _Nonnull stop) {
157
- [files addObject: ours.path];
158
- }];
139
+ }
159
140
160
- if (error != NULL ) {
161
- NSDictionary *userInfo = @{GTPullMergeConflictedFiles: files};
162
- *error = [NSError git_errorFor: GIT_ECONFLICT description: @" Merge conflict" userInfo: userInfo failureReason: nil ];
163
- }
141
+ // Do normal merge
142
+ GTTree *localTree = localCommit.tree ;
143
+ GTTree *remoteTree = remoteCommit.tree ;
164
144
165
- // Write conflicts
166
- git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
167
- git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
168
- checkout_opts.checkout_strategy = (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS);
145
+ // TODO: Find common ancestor
146
+ GTTree *ancestorTree = nil ;
169
147
170
- git_annotated_commit *annotatedCommit;
171
- [self annotatedCommit: &annotatedCommit fromCommit: remoteCommit error: error];
148
+ // Merge
149
+ GTIndex *index = [localTree merge: remoteTree ancestor: ancestorTree error: error];
150
+ if (!index) {
151
+ return NO ;
152
+ }
172
153
173
- git_merge (self.git_repository , (const git_annotated_commit **)&annotatedCommit, 1 , &merge_opts, &checkout_opts);
154
+ // Check for conflict
155
+ if (index.hasConflicts ) {
156
+ NSMutableArray <NSString *>*files = [NSMutableArray array ];
157
+ [index enumerateConflictedFilesWithError: error usingBlock: ^(GTIndexEntry * _Nonnull ancestor, GTIndexEntry * _Nonnull ours, GTIndexEntry * _Nonnull theirs, BOOL * _Nonnull stop) {
158
+ [files addObject: ours.path];
159
+ }];
174
160
175
- return NO ;
161
+ if (error != NULL ) {
162
+ NSDictionary *userInfo = @{GTPullMergeConflictedFiles: files};
163
+ *error = [NSError git_errorFor: GIT_ECONFLICT description: @" Merge conflict" userInfo: userInfo failureReason: nil ];
176
164
}
177
165
178
- GTTree *newTree = [index writeTreeToRepository: self error: error];
179
- if (!newTree) {
180
- return NO ;
181
- }
166
+ // Write conflicts
167
+ git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
168
+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT ;
169
+ checkout_opts. checkout_strategy = (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS);
182
170
183
- // Create merge commit
184
- NSString *message = [NSString stringWithFormat: @" Merge branch '%@ '" , localBranch.shortName];
185
- NSArray *parents = @[ localCommit, remoteCommit ];
171
+ git_annotated_commit *annotatedCommit;
172
+ [self annotatedCommit: &annotatedCommit fromCommit: remoteCommit error: error];
186
173
187
- // FIXME: This is stepping on the local tree
188
- GTCommit *mergeCommit = [self createCommitWithTree: newTree message: message parents: parents updatingReferenceNamed: localBranch.reference.name error: error];
189
- if (!mergeCommit) {
190
- return NO ;
191
- }
174
+ git_merge (self.git_repository , (const git_annotated_commit **)&annotatedCommit, 1 , &merge_opts, &checkout_opts);
192
175
193
- BOOL success = [self checkoutReference: localBranch.reference options: [GTCheckoutOptions checkoutOptionsWithStrategy: GTCheckoutStrategyForce] error: error];
194
- return success;
176
+ return NO ;
177
+ }
178
+
179
+ GTTree *newTree = [index writeTreeToRepository: self error: error];
180
+ if (!newTree) {
181
+ return NO ;
182
+ }
183
+
184
+ // Create merge commit
185
+ NSString *message = [NSString stringWithFormat: @" Merge branch '%@ '" , localBranch.shortName];
186
+ NSArray *parents = @[ localCommit, remoteCommit ];
187
+
188
+ // FIXME: This is stepping on the local tree
189
+ GTCommit *mergeCommit = [self createCommitWithTree: newTree message: message parents: parents updatingReferenceNamed: localBranch.reference.name error: error];
190
+ if (!mergeCommit) {
191
+ return NO ;
195
192
}
196
193
197
- return NO ;
194
+ success = [self checkoutReference: localBranch.reference options: [GTCheckoutOptions checkoutOptionsWithStrategy: GTCheckoutStrategyForce] error: error];
195
+ return success;
198
196
}
199
197
200
198
- (NSString * _Nullable)contentsOfDiffWithAncestor : (GTIndexEntry *)ancestor ourSide : (GTIndexEntry *)ourSide theirSide : (GTIndexEntry *)theirSide error : (NSError **)error {
0 commit comments