Skip to content
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

Fix two APIs #1041

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions GitUpKit/Core/GCIndex.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ - (BOOL)checkoutFileToWorkingDirectory:(NSString*)path fromIndex:(GCIndex*)index
}

- (BOOL)checkoutFilesToWorkingDirectory:(NSArray<NSString*>*)paths fromIndex:(GCIndex*)index error:(NSError**)error {
if ([paths count] == 0) {
return YES;
}

git_checkout_options options = GIT_CHECKOUT_OPTIONS_INIT;
options.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_DONT_UPDATE_INDEX; // There's no reason to update the index
options.paths.count = paths.count;
Expand Down
10 changes: 5 additions & 5 deletions GitUpKit/Core/GCRepository+Bare.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (GCCommit*)_mergeTheirCommit:(git_commit*)theirCommit
for (NSUInteger i = 0; i < count; ++i) {
[array addObject:_CopyCommit(self, (git_commit*)parents[i])];
}
commit = handler([[GCIndex alloc] initWithRepository:nil index:index], _CopyCommit(self, ourCommit), _CopyCommit(self, theirCommit), array, message, error); // Doesn't make sense to specify a custom author on conflict anyway
commit = handler([[GCIndex alloc] initWithRepository:nil index:index], ourCommit ? _CopyCommit(self, ourCommit) : nil, _CopyCommit(self, theirCommit), array, message, error); // Doesn't make sense to specify a custom author on conflict anyway
index = NULL; // Ownership has been transferred to GCIndex instance
} else {
commit = [self createCommitFromIndex:index withParents:parents count:count author:author message:message error:error];
Expand All @@ -95,12 +95,12 @@ - (GCCommit*)cherryPickCommit:(GCCommit*)pickCommit
message:(NSString*)message
conflictHandler:(GCConflictHandler)handler
error:(NSError**)error {
const git_commit* parents[] = {againstCommit.private};
const git_commit** parents = (againstCommit != nil) ? (git_commit*[]) {againstCommit.private} : (git_commit*[]) {};
return [self _mergeTheirCommit:pickCommit.private
intoOurCommit:againstCommit.private
withAncestorCommit:ancestorCommit.private
parents:parents
count:1
count:(againstCommit != nil) ? 1 : 0
author:git_commit_author(pickCommit.private)
message:message
conflictHandler:handler
Expand All @@ -113,12 +113,12 @@ - (GCCommit*)revertCommit:(GCCommit*)revertCommit
message:(NSString*)message
conflictHandler:(GCConflictHandler)handler
error:(NSError**)error {
const git_commit* parents[] = {againstCommit.private};
const git_commit** parents = (againstCommit != nil) ? (git_commit*[]) {againstCommit.private} : (git_commit*[]) {};
return [self _mergeTheirCommit:ancestorCommit.private
intoOurCommit:againstCommit.private
withAncestorCommit:revertCommit.private
parents:parents
count:1
count:(againstCommit != nil) ? 1 : 0
author:NULL
message:message
conflictHandler:handler
Expand Down