8000 Add -[GTRepository checkoutTree:…] method by slavikus · Pull Request #608 · libgit2/objective-git · GitHub
[go: up one dir, main page]

Skip to content

Add -[GTRepository checkoutTree:…] method #608

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

Merged
merged 3 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
10000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix conflicts from #459
# Conflicts:
#	ObjectiveGit/GTRepository.h
#	ObjectiveGit/GTRepository.m
  • Loading branch information
slavikus committed Feb 27, 2017
commit ed7e21a41f9f6ace820c29e4ea8bc4f55dcadd43
33 changes: 14 additions & 19 deletions ObjectiveGit/GTRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,36 +519,31 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {

/// Checkout a reference
///
/// targetReference - The reference to checkout.
/// strategy - The checkout strategy to use.
/// notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
/// to be called.
/// error - The error if one occurred. Can be NULL.
/// notifyBlock - The block to call back for notification handling. Can be nil.
/// progressBlock - The block to call back for progress updates. Can be nil.
/// targetReference - The reference to checkout. Must not be nil.
/// options - The checkout options to use. Can be nil.
/// error - The error if one occurred. Can be NULL.
///
/// Returns YES if operation was successful, NO otherwise
- (BOOL)checkoutReference:(GTReference *)targetReference options:(nullable GTCheckoutOptions *)options error:(NSError **)error;

/// Checkout an index
///
/// index - The index to checkout. Must not be nil.
/// options - The checkout options to use. Can be nil.
/// error - The error if one occurred. Can be NULL.
///
/// Returns YES if operation was successful, NO otherwise
- (BOOL)checkoutIndex:(GTIndex *)index options:(nullable GTCheckoutOptions *)options error:(NSError **)error;

/// Checkout a tree
///
/// targetTree - The tree to checkout.
/// strategy - The checkout strategy to use.
/// notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
/// to be called.
/// options - The checkout options to use. Can be nil.
/// error - The error if one occurred. Can be NULL.
/// notifyBlock - The block to call back for notification handling. Can be nil.
/// progressBlock - The block to call back for progress updates. Can be nil.
///
/// Returns YES if operation was successful, NO otherwise
/// Note: this operation will NOT update HEAD to newly checked out tree.
- (BOOL)checkoutTree:(GTTree *)targetTree strategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock notifyBlock:(nullable int (^)(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir))notifyBlock;

/// Convenience wrapper for checkoutCommit:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
- (BOOL)checkoutCommit:(GTCommit *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;

/// Convenience wrapper for checkoutReference:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
- (BOOL)checkoutReference:(GTReference *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
- (BOOL)checkoutTree:(GTTree *)targetTree options:(nullable GTCheckoutOptions *)options error:(NSError **)error;

/// Flush the gitattributes cache.
- (void)flushAttributesCache;
Expand Down
17 changes: 9 additions & 8 deletions ObjectiveGit/GTRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,17 @@ - (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOpti
return [self moveHEADToReference:targetReference error:error];
}

- (BOOL)checkoutTree:(GTTree *)targetTree strategy:(GTCheckoutStrategyType)strategy notifyFlags:(GTCheckoutNotifyFlags)notifyFlags error:(NSError **)error progressBlock:(GTCheckoutProgressBlock)progressBlock notifyBlock:(GTCheckoutNotifyBlock)notifyBlock {
return [self performCheckout:targetTree withStrategy:strategy notifyFlags:notifyFlags error:error progressBlock:progressBlock notifyBlock:notifyBlock];
- (BOOL)checkoutTree:(GTTree *)targetTree options:(nullable GTCheckoutOptions *)options error:(NSError **)error {
return [self performCheckout:targetTree options:options error:error];
}

- (BOOL)checkoutCommit:(GTCommit *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(GTCheckoutProgressBlock)progressBlock {
return [self checkoutCommit:target strategy:strategy notifyFlags:GTCheckoutNotifyNone error:error progressBlock:progressBlock notifyBlock:nil];
}

- (BOOL)checkoutReference:(GTReference *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(GTCheckoutProgressBlock)progressBlock {
return [self checkoutReference:target strategy:strategy notifyFlags:GTCheckoutNotifyNone error:error progressBlock:progressBlock notifyBlock:nil];
- (BOOL)checkoutIndex:(GTIndex *)index options:(GTCheckoutOptions *)options error:(NSError **)error {
int gitError = git_checkout_index(self.git_repository, index.git_index, options.git_checkoutOptions);
if (gitError < GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to checkout index."];
return NO;
}
return YES;
}

- (void)flushAttributesCache {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0