-
Notifications
You must be signed in to change notification settings - Fork 281
Wrap git_merge_file #630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap git_merge_file #630
Conversation
Just some changes I had lying around. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: Thanks a lot for the PullRequest! As there is a lot going on some tests to verify the functionality would be great.
ObjectiveGit/GTRepository+Merging.h
Outdated
/// error - The error if one occurred. Can be NULL. | ||
/// | ||
/// Returns The file content annotated with conflict markers or null on error | ||
- (NSString* _Nullable)stringForConflictWithAncestor:(GTIndexEntry *)ancestor ourSide:(GTIndexEntry *)ourSide theirSide:(GTIndexEntry *)theirSide withError:(NSError **)error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpicks :
*
should be right-alignedwithError:
=>error:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few more *
spacing weirdness in the hunk below as well.
ObjectiveGit/GTRepository+Merging.m
Outdated
|
||
|
||
git_merge_file_result result; | ||
git_merge_file(&result, &ancestorInput, &ourInput, &theirInput, nil); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error checking.
Thanks for the PR ! A few more thoughts though :
|
@tiennou thanks for the feedback! I'll fix it this weekend. |
Addressed the main issues. The test is pretty messy, but I don't see a nicer or shorter way to produce conflicting commits on two different branches and merging them. |
This should be ready. |
strncpy(cString, result.ptr, result.len); | ||
cString[result.len] = '\0'; | ||
|
||
NSString *mergedContent = [[NSString alloc] initWithCString:cString encoding:NSUTF8StringEncoding]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe -initWithBytesNoCopy:length:encoding:freeWhenDone:
? That should allow you to just pass result.ptr
/result.len
, skipping the need for the malloc
/strncpy
step. You would have to result.ptr = NULL
though, so git_merge_file_result_free
doesn't break it by freeing before returning.
After a more thorough look at what |
I could wrap |
I'm ok with not having a wrapper for now. |
Add a wrapper for git_merge_file