8000 Add list of files to merge conflict error · libgit2/objective-git@eb0f40f · GitHub
[go: up one dir, main page]

Skip to content

Commit eb0f40f

Browse files
committed
Add list of files to merge conflict error
1 parent 183232f commit eb0f40f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ObjectiveGit/GTRepository+Pull.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "GTRepository+RemoteOperations.h"
1818
#import "GTTree.h"
1919
#import "NSError+Git.h"
20+
#import "GTIndexEntry.h"
2021
#import "git2/errors.h"
2122

2223
@implementation GTRepository (Pull)
@@ -106,7 +107,17 @@ - (BOOL)pullBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:
106107

107108
// Check for conflict
108109
if (index.hasConflicts) {
109-
if (error != NULL) *error = [NSError git_errorFor:GIT_ECONFLICT description:@"Merge conflict, pull aborted"];
110+
NSMutableArray <NSString *>*files = [NSMutableArray array];
111+
[index enumerateConflictedFilesWithError:error usingBlock:^(GTIndexEntry * _Nonnull ancestor, GTIndexEntry * _Nonnull ours, GTIndexEntry * _Nonnull theirs, BOOL * _Nonnull stop) {
112+
[files addObject:ours.path];
113+
}];
114+
if (error != NULL) {
115+
if (files.count > 0) {
116+
*error = [NSError git_errorFor:GIT_ECONFLICT description:@"Merge conflict in files: %@. Pull aborted.", [files componentsJoinedByString:@", "]];
117+
} else {
118+
*error = [NSError git_errorFor:GIT_ECONFLICT description:@"Merge conflict, pull aborted"];
119+
}
120+
}
110121
return NO;
111122
}
112123

0 commit comments

Comments
 (0)
0