Skip to content

Commit 177938a

Browse files
authored
Merge pull request #608 from slavikus/add-checkout-tree
Add -[GTRepository checkoutTree:…] method
2 parents d59731d + ed7e21a commit 177938a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ObjectiveGit/GTRepository.h

+10
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,16 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
535535
/// Returns YES if operation was successful, NO otherwise
536536
- (BOOL)checkoutIndex:(GTIndex *)index options:(nullable GTCheckoutOptions *)options error:(NSError **)error;
537537

538+
/// Checkout a tree
539+
///
540+
/// targetTree - The tree to checkout.
541+
/// options - The checkout options to use. Can be nil.
542+
/// error - The error if one occurred. Can be NULL.
543+
///
544+
/// Returns YES if operation was successful, NO otherwise
545+
/// Note: this operation will NOT update HEAD to newly checked out tree.
546+
- (BOOL)checkoutTree:(GTTree *)targetTree options:(nullable GTCheckoutOptions *)options error:(NSError **)error;
547+
538548
/// Flush the gitattributes cache.
539549
- (void)flushAttributesCache;
540550

ObjectiveGit/GTRepository.m

+4
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,10 @@ - (BOOL)checkoutReference:(GTReference *)targetReference options:(GTCheckoutOpti
830830
return [self moveHEADToReference:targetReference error:error];
831831
}
832832

833+
- (BOOL)checkoutTree:(GTTree *)targetTree options:(nullable GTCheckoutOptions *)options error:(NSError **)error {
834+
return [self performCheckout:targetTree options:options error:error];
835+
}
836+
833837
- (BOOL)checkoutIndex:(GTIndex *)index options:(GTCheckoutOptions *)options error:(NSError **)error {
834838
int gitError = git_checkout_index(self.git_repository, index.git_index, options.git_checkoutOptions);
835839
if (gitError < GIT_OK) {

0 commit comments

Comments
 (0)