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"
5556
5657NS_ASSUME_NONNULL_BEGIN
5758
58- // / Checkout strategies used by the various -checkout... methods
59- // / See git_checkout_strategy_t
60- typedef NS_OPTIONS (NSInteger , GTCheckoutStrategyType) {
61- GTCheckoutStrategyNone = GIT_CHECKOUT_NONE,
62- GTCheckoutStrategySafe = GIT_CHECKOUT_SAFE,
63- GTCheckoutStrategyForce = GIT_CHECKOUT_FORCE,
64- GTCheckoutStrategyAllowConflicts = GIT_CHECKOUT_ALLOW_CONFLICTS,
65- GTCheckoutStrategyRemoveUntracked = GIT_CHECKOUT_REMOVE_UNTRACKED,
66- GTCheckoutStrategyRemoveIgnored = GIT_CHECKOUT_REMOVE_IGNORED,
67- GTCheckoutStrategyUpdateOnly = GIT_CHECKOUT_UPDATE_ONLY,
68- GTCheckoutStrategyDontUpdateIndex = GIT_CHECKOUT_DONT_UPDATE_INDEX,
69- GTCheckoutStrategyNoRefresh = GIT_CHECKOUT_NO_REFRESH,
70- GTCheckoutStrategyDisablePathspecMatch = GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH,
71- GTCheckoutStrategySkipLockedDirectories = GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES,
72- };
73-
74- // / Checkout notification flags used by the various -checkout... methods
75- // / See git_checkout_notify_t
76- typedef NS_OPTIONS (NSInteger , GTCheckoutNotifyFlags) {
77- GTCheckoutNotifyNone = GIT_CHECKOUT_NOTIFY_NONE,
78- GTCheckoutNotifyConflict = GIT_CHECKOUT_NOTIFY_CONFLICT,
79- GTCheckoutNotifyDirty = GIT_CHECKOUT_NOTIFY_DIRTY,
80- GTCheckoutNotifyUpdated = GIT_CHECKOUT_NOTIFY_UPDATED,
81- GTCheckoutNotifyUntracked = GIT_CHECKOUT_NOTIFY_UNTRACKED,
82- GTCheckoutNotifyIgnored = GIT_CHECKOUT_NOTIFY_IGNORED,
83-
84- GTCheckoutNotifyAll = GIT_CHECKOUT_NOTIFY_ALL,
85- };
86-
8759// / Transport flags sent as options to +cloneFromURL... method
8860typedef NS_OPTIONS (NSInteger , GTTransportFlags) {
8961 GTTransportFlagsNone = GIT_TRANSPORTFLAGS_NONE
@@ -101,6 +73,9 @@ extern NSString * const GTRepositoryCloneOptionsBare;
10173// / Default value is `YES`.
10274extern NSString * const GTRepositoryCloneOptionsCheckout;
10375
76+ // / A `GTCheckoutOptions` object describing how to perform the checkout.
77+ extern NSString * const GTRepositoryCloneCheckoutOptions;
78+
10479// / A `GTCredentialProvider`, that will be used to authenticate against the
10580// / remote.
10681extern NSString * const GTRepositoryCloneOptionsCredentialProvider;
@@ -253,7 +228,7 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
253228// / options - A dictionary consisting of the options:
254229// / `GTRepositoryCloneOptionsTransportFlags`,
255230// / `GTRepositoryCloneOptionsBare`,
256- // / `GTRepositoryCloneOptionsCheckout `,
231+ // / `GTRepositoryCloneCheckoutOptions `,
257232// / `GTRepositoryCloneOptionsCredentialProvider`,
258233// / `GTRepositoryCloneOptionsCloneLocal`,
259234// / `GTRepositoryCloneOptionsServerCertificateURL`
@@ -265,6 +240,9 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
265240// / May be NULL.
266241// /
267242// / returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful.
243+ + (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;
244+
245+ // / Backward-compatible method that uses `GTRepositoryCloneOptionsCheckout`
268246+ (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;
269247
270248// / Lookup objects in the repo by oid or sha1
@@ -536,34 +514,20 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
536514// / Checkout a commit
537515// /
538516// / targetCommit - The commit to checkout. Must not be nil.
539- // / strategy - The checkout strategy to use.
540- // / notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
541- // / to be called.
517+ // / options - The checkout options to use. Can be nil.
542518// / error - The error if one occurred. Can be NULL.
543- // / notifyBlock - The block to call back for notification handling. Can be nil.
544- // / progressBlock - The block to call back for progress updates. Can be nil.
545519// /
546520// / Returns YES if operation was successful, NO otherwise
547- - (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 ;
521+ - (BOOL )checkoutCommit : (GTCommit *)targetCommit options : ( nullable GTCheckoutOptions *) options error : ( NSError **) error ;
548522
549523// / Checkout a reference
550524// /
551- // / targetCommit - The reference to checkout.
552- // / strategy - The checkout strategy to use.
553- // / notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
554- // / to be called.
555- // / error - The error if one occurred. Can be NULL.
556- // / notifyBlock - The block to call back for notification handling. Can be nil.
557- // / progressBlock - The block to call back for progress updates. Can be nil.
525+ // / targetReference - The reference to checkout. Must not be nil.
526+ // / options - The checkout options to use. Can be nil.
527+ // / error - The error if one occurred. Can be NULL.
558528// /
559529// / Returns YES if operation was successful, NO otherwise
560- - (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;
561-
562- // / Convenience wrapper for checkoutCommit:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
563- - (BOOL )checkoutCommit:(GTCommit *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
564-
565- // / Convenience wrapper for checkoutReference:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
566- - (BOOL )checkoutReference:(GTReference *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
530+ - (BOOL )checkoutReference : (GTReference *)targetReference options : (nullable GTCheckoutOptions *)options error : (NSError **)error ;
567531
568532// / Flush the gitattributes cache.
569533- (void )flushAttributesCache ;
0 commit comments