Skip to content

Commit 6e7b6c2

Browse files
committed
Revert to "default enabled" behavior of checking out when cloning
This adds back a renamed version of the old BOOL options and sets a GTCheckoutOptions with sane defaults
1 parent 177938a commit 6e7b6c2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

ObjectiveGit/GTRepository.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ extern NSString * const GTRepositoryCloneOptionsBare;
7171

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

7676
/// A `GTCheckoutOptions` object describing how to perform the checkout.
77-
extern NSString * const GTRepositoryCloneCheckoutOptions;
77+
extern NSString * const GTRepositoryCloneOptionsCheckoutOptions;
7878

7979
/// A `GTCredentialProvider`, that will be used to authenticate against the
8080
/// remote.

ObjectiveGit/GTRepository.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
#import "git2.h"
6161

6262
NSString * const GTRepositoryCloneOptionsBare = @"GTRepositoryCloneOptionsBare";
63-
NSString * const GTRepositoryCloneCheckoutOptions = @"GTRepositoryCloneCheckoutOptions";
63+
NSString * const GTRepositoryCloneOptionsPerformCheckout = @"GTRepositoryCloneOptionsPerformCheckout";
64+
NSString * const GTRepositoryCloneOptionsCheckoutOptions = @"GTRepositoryCloneOptionsCheckoutOptions";
6465
NSString * const GTRepositoryCloneOptionsTransportFlags = @"GTRepositoryCloneOptionsTransportFlags";
6566
NSString * const GTRepositoryCloneOptionsCredentialProvider = @"GTRepositoryCloneOptionsCredentialProvider";
6667
NSString * const GTRepositoryCloneOptionsCloneLocal = @"GTRepositoryCloneOptionsCloneLocal";
@@ -248,7 +249,14 @@ + (nullable instancetype)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSU
248249
NSNumber *bare = options[GTRepositoryCloneOptionsBare];
249250
cloneOptions.bare = (bare == nil ? 0 : bare.boolValue);
250251

251-
GTCheckoutOptions *checkoutOptions = options[GTRepositoryCloneCheckoutOptions];
252+
NSNumber *checkout = options[GTRepositoryCloneOptionsPerformCheckout];
253+
BOOL doCheckout = (checkout != nil ? [checkout boolValue] : YES);
254+
255+
GTCheckoutOptions *checkoutOptions = options[GTRepositoryCloneOptionsCheckoutOptions];
256+
if (checkoutOptions == nil && doCheckout) {
257+
checkoutOptions = [GTCheckoutOptions checkoutOptionsWithStrategy:GTCheckoutStrategySafe];
258+
}
259+
252260
if (checkoutOptions != nil) {
253261
cloneOptions.checkout_opts = *(checkoutOptions.git_checkoutOptions);
254262
}

0 commit comments

Comments
 (0)