3434#import " GTObject.h"
3535#import " GTReference.h"
3636#import " GTFilterList.h"
37+ #import " GTCheckoutOptions.h"
3738#import " git2/checkout.h"
3839#import " git2/repository.h"
3940#import " git2/transport.h"
5455
5556NS_ASSUME_NONNULL_BEGIN
5657
57- // / Checkout strategies used by the various -checkout... methods
58- // / See git_checkout_strategy_t
59- typedef NS_OPTIONS (NSInteger , GTCheckoutStrategyType) {
60- GTCheckoutStrategyNone = GIT_CHECKOUT_NONE ,
61- GTCheckoutStrategySafe = GIT_CHECKOUT_SAFE ,
62- GTCheckoutStrategyForce = GIT_CHECKOUT_FORCE ,
63- GTCheckoutStrategyAllowConflicts = GIT_CHECKOUT_ALLOW_CONFLICTS ,
64- GTCheckoutStrategyRemoveUntracked = GIT_CHECKOUT_REMOVE_UNTRACKED ,
65- GTCheckoutStrategyRemoveIgnored = GIT_CHECKOUT_REMOVE_IGNORED ,
66- GTCheckoutStrategyUpdateOnly = GIT_CHECKOUT_UPDATE_ONLY ,
67- GTCheckoutStrategyDontUpdateIndex = GIT_CHECKOUT_DONT_UPDATE_INDEX ,
68- GTCheckoutStrategyNoRefresh = GIT_CHECKOUT_NO_REFRESH ,
69- GTCheckoutStrategyDisablePathspecMatch = GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH ,
70- GTCheckoutStrategySkipLockedDirectories = GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES ,
71- };
72-
73- // / Checkout notification flags used by the various -checkout... methods
74- // / See git_checkout_notify_t
75- typedef NS_OPTIONS (NSInteger , GTCheckoutNotifyFlags) {
76- GTCheckoutNotifyNone = GIT_CHECKOUT_NOTIFY_NONE ,
77- GTCheckoutNotifyConflict = GIT_CHECKOUT_NOTIFY_CONFLICT ,
78- GTCheckoutNotifyDirty = GIT_CHECKOUT_NOTIFY_DIRTY ,
79- GTCheckoutNotifyUpdated = GIT_CHECKOUT_NOTIFY_UPDATED ,
80- GTCheckoutNotifyUntracked = GIT_CHECKOUT_NOTIFY_UNTRACKED ,
81- GTCheckoutNotifyIgnored = GIT_CHECKOUT_NOTIFY_IGNORED ,
82-
83- GTCheckoutNotifyAll = GIT_CHECKOUT_NOTIFY_ALL ,
84- };
85-
8658// / Transport flags sent as options to +cloneFromURL... method
8759typedef NS_OPTIONS (NSInteger , GTTransportFlags) {
8860 GTTransportFlagsNone = GIT_TRANSPORTFLAGS_NONE
@@ -100,6 +72,9 @@ extern NSString * const GTRepositoryCloneOptionsBare;
10072// / Default value is `YES`.
10173extern NSString * const GTRepositoryCloneOptionsCheckout;
10274
75+ // / A `GTCheckoutOptions` object describing how to perform the checkout.
76+ extern NSString * const GTRepositoryCloneCheckoutOptions;
77+
10378// / A `GTCredentialProvider`, that will be used to authenticate against the
10479// / remote.
10580extern NSString * const GTRepositoryCloneOptionsCredentialProvider;
@@ -230,7 +205,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
230205// / options - A dictionary consisting of the options:
231206// / `GTRepositoryCloneOptionsTransportFlags`,
232207// / `GTRepositoryCloneOptionsBare`,
233- // / `GTRepositoryCloneOptionsCheckout `,
208+ // / `GTRepositoryCloneCheckoutOptions `,
234209// / `GTRepositoryCloneOptionsCredentialProvider`,
235210// / `GTRepositoryCloneOptionsCloneLocal`,
236211// / `GTRepositoryCloneOptionsServerCertificateURL`
@@ -242,6 +217,9 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
242217// / May be NULL.
243218// /
244219// / returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful.
220+ + (nullable instancetype )cloneFromURL : (NSURL *)originURL toWorkingDirectory : (NSURL *)workdirURL options : (nullable NSDictionary *)options error : (NSError **)error transferProgressBlock : (nullable void (^)(const git_transfer_progress *, BOOL *stop))transferProgressBlock;
221+
222+ // / Backward-compatible method that uses `GTRepositoryCloneOptionsCheckout`
245223+ (nullable instancetype )cloneFromURL : (NSURL *)originURL toWorkingDirectory : (NSURL *)workdirURL options : (nullable NSDictionary *)options error : (NSError **)error transferProgressBlock : (nullable void (^)(const git_transfer_progress *, BOOL *stop))transferProgressBlock checkoutProgressBlock:(nullable void (^) (NSString *__nullable path, NSUInteger completedSteps, NSUInteger totalSteps))checkoutProgressBlock;
246224
247225// / Lookup objects in the repo by oid or sha1
@@ -513,34 +491,20 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
513491// / Checkout a commit
514492// /
515493// / targetCommit - The commit to checkout. Must not be nil.
516- // / strategy - The checkout strategy to use.
517- // / notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
518- // / to be called.
494+ // / options - The checkout options to use. Can be nil.
519495// / error - The error if one occurred. Can be NULL.
520- // / notifyBlock - The block to call back for notification handling. Can be nil.
521- // / progressBlock - The block to call back for progress updates. Can be nil.
522496// /
523497// / Returns YES if operation was successful, NO otherwise
524- - (BOOL )checkoutCommit : (GTCommit *)targetCommit 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 ;
498+ - (BOOL )checkoutCommit : (GTCommit *)targetCommit options : ( nullable GTCheckoutOptions *) options error : ( NSError **) error ;
525499
526500// / Checkout a reference
527501// /
528- // / targetCommit - The reference to checkout.
529- // / strategy - The checkout strategy to use.
530- // / notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
531- // / to be called.
532- // / error - The error if one occurred. Can be NULL.
533- // / notifyBlock - The block to call back for notification handling. Can be nil.
534- // / progressBlock - The block to call back for progress updates. Can be nil.
502+ // / targetReference - The reference to checkout. Must not be nil.
503+ // / options - The checkout options to use. Can be nil.
504+ // / error - The error if one occurred. Can be NULL.
535505// /
536506// / Returns YES if operation was successful, NO otherwise
537- - (BOOL )checkoutReference:(GTReference *)targetReference 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;
538-
539- // / Convenience wrapper for checkoutCommit:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
540- - (BOOL )checkoutCommit:(GTCommit *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
541-
542- // / Convenience wrapper for checkoutReference:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
543- - (BOOL )checkoutReference:(GTReference *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
507+ - (BOOL )checkoutReference : (GTReference *)targetReference options : (nullable GTCheckoutOptions *)options error : (NSError **)error ;
544508
545509// / Flush the gitattributes cache.
546510- (void )flushAttributesCache ;
0 commit comments