Skip to content

Revert to "default enabled" behavior of checking out when cloning #619

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
Mar 4, 2017
Merged
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
9 changes: 4 additions & 5 deletions ObjectiveGit/GTRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ extern NSString * const GTRepositoryCloneOptionsBare;

/// An `NSNumber` wrapped `BOOL`, if NO, don't checkout the remote HEAD.
/// Default value is `YES`.
extern NSString * const GTRepositoryCloneOptionsCheckout;
extern NSString * const GTRepositoryCloneOptionsPerformCheckout;

/// A `GTCheckoutOptions` object describing how to perform the checkout.
extern NSString * const GTRepositoryCloneCheckoutOptions;
extern NSString * const GTRepositoryCloneOptionsCheckoutOptions;

/// A `GTCredentialProvider`, that will be used to authenticate against the
/// remote.
Expand Down Expand Up @@ -228,15 +228,14 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
/// options - A dictionary consisting of the options:
/// `GTRepositoryCloneOptionsTransportFlags`,
/// `GTRepositoryCloneOptionsBare`,
/// `GTRepositoryCloneCheckoutOptions`,
/// `GTRepositoryCloneOptionsPerformCheckout`,
/// `GTRepositoryCloneOptionsCheckoutOptions`,
/// `GTRepositoryCloneOptionsCredentialProvider`,
/// `GTRepositoryCloneOptionsCloneLocal`,
/// `GTRepositoryCloneOptionsServerCertificateURL`
/// error - A pointer to fill in case of trouble.
/// transferProgressBlock - This block is called with network transfer updates.
/// May be NULL.
/// checkoutProgressBlock - This block is called with checkout updates
/// (if `GTRepositoryCloneOptionsCheckout` is YES).
/// May be NULL.
///
/// returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful.
Expand Down
12 changes: 10 additions & 2 deletions ObjectiveGit/GTRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
#import "git2.h"

NSString * const GTRepositoryCloneOptionsBare = @"GTRepositoryCloneOptionsBare";
NSString * const GTRepositoryCloneCheckoutOptions = @"GTRepositoryCloneCheckoutOptions";
NSString * const GTRepositoryCloneOptionsPerformCheckout = @"GTRepositoryCloneOptionsPerformCheckout";
NSString * const GTRepositoryCloneOptionsCheckoutOptions = @"GTRepositoryCloneOptionsCheckoutOptions";
NSString * const GTRepositoryCloneOptionsTransportFlags = @"GTRepositoryCloneOptionsTransportFlags";
NSString * const GTRepositoryCloneOptionsCredentialProvider = @"GTRepositoryCloneOptionsCredentialProvider";
NSString * const GTRepositoryCloneOptionsCloneLocal = @"GTRepositoryCloneOptionsCloneLocal";
Expand Down Expand Up @@ -248,7 +249,14 @@ + (nullable instancetype)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSU
NSNumber *bare = options[GTRepositoryCloneOptionsBare];
cloneOptions.bare = (bare == nil ? 0 : bare.boolValue);

GTCheckoutOptions *checkoutOptions = options[GTRepositoryCloneCheckoutOptions];
NSNumber *checkout = options[GTRepositoryCloneOptionsPerformCheckout];
BOOL doCheckout = (checkout != nil ? [checkout boolValue] : YES);

GTCheckoutOptions *checkoutOptions = options[GTRepositoryCloneOptionsCheckoutOptions];
if (checkoutOptions == nil && doCheckout) {
checkoutOptions = [GTCheckoutOptions checkoutOptionsWithStrategy:GTCheckoutStrategySafe];
}

if (checkoutOptions != nil) {
cloneOptions.checkout_opts = *(checkoutOptions.git_checkoutOptions);
}
Expand Down
8 changes: 4 additions & 4 deletions ObjectiveGitTests/GTRepositorySpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

NSDictionary *cloneOptions = @{
GTRepositoryCloneOptionsCloneLocal: @YES,
GTRepositoryCloneCheckoutOptions: checkoutOptions,
GTRepositoryCloneOptionsCheckoutOptions: checkoutOptions,
};
repository = [GTRepository cloneFromURL:originURL toWorkingDirectory:workdirURL options:cloneOptions error:&error transferProgressBlock:transferProgressBlock];
expect(repository).notTo(beNil());
Expand All @@ -125,7 +125,7 @@
NSDictionary *options = @{
GTRepositoryCloneOptionsBare: @YES,
GTRepositoryCloneOptionsCloneLocal: @YES,
GTRepositoryCloneCheckoutOptions: checkoutOptions,
GTRepositoryCloneOptionsCheckoutOptions: checkoutOptions,
};
repository = [GTRepository cloneFromURL:originURL toWorkingDirectory:workdirURL options:options error:&error transferProgressBlock:transferProgressBlock];
expect(repository).notTo(beNil());
Expand All @@ -147,7 +147,7 @@
GTCheckoutOptions *checkoutOptions = [GTCheckoutOptions checkoutOptionsWithStrategy:GTCheckoutStrategySafe];
checkoutOptions.progressBlock = checkoutProgressBlock;

repository = [GTRepository cloneFromURL:originURL toWorkingDirectory:workdirURL options:@{ GTRepositoryCloneCheckoutOptions: checkoutOptions } error:&error transferProgressBlock:transferProgressBlock];
repository = [GTRepository cloneFromURL:originURL toWorkingDirectory:workdirURL options:@{ GTRepositoryCloneOptionsCheckoutOptions: checkoutOptions } error:&error transferProgressBlock:transferProgressBlock];
expect(repository).notTo(beNil());
expect(error).to(beNil());

Expand Down Expand Up @@ -188,7 +188,7 @@
checkoutOptions.progressBlock = checkoutProgressBlock;
NSDictionary *cloneOptions = @{
GTRepositoryCloneOptionsCredentialProvider: provider,
GTRepositoryCloneCheckoutOptions: checkoutOptions,
GTRepositoryCloneOptionsCheckoutOptions: checkoutOptions,
};

repository = [GTRepository cloneFromURL:originURL toWorkingDirectory:workdirURL options:cloneOptions error:&error transferProgressBlock:transferProgressBlock];
Expand Down