34
34
#import " GTObject.h"
35
35
#import " GTReference.h"
36
36
#import " GTFilterList.h"
37
+ #import " GTCheckoutOptions.h"
37
38
#import " git2/checkout.h"
38
39
#import " git2/repository.h"
39
40
#import " git2/transport.h"
54
55
55
56
NS_ASSUME_NONNULL_BEGIN
56
57
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
-
86
58
// / Transport flags sent as options to +cloneFromURL... method
87
59
typedef NS_OPTIONS (NSInteger , GTTransportFlags) {
88
60
GTTransportFlagsNone = GIT_TRANSPORTFLAGS_NONE
@@ -100,6 +72,9 @@ extern NSString * const GTRepositoryCloneOptionsBare;
100
72
// / Default value is `YES`.
101
73
extern NSString * const GTRepositoryCloneOptionsCheckout;
102
74
75
+ // / A `GTCheckoutOptions` object describing how to perform the checkout.
76
+ extern NSString * const GTRepositoryCloneCheckoutOptions;
77
+
103
78
// / A `GTCredentialProvider`, that will be used to authenticate against the
104
79
// / remote.
105
80
extern NSString * const GTRepositoryCloneOptionsCredentialProvider;
@@ -216,7 +191,7 @@ extern NSString * const GTRepositoryInitOptionsOriginURLString;
216
191
// / options - A dictionary consisting of the options:
217
192
// / `GTRepositoryCloneOptionsTransportFlags`,
218
193
// / `GTRepositoryCloneOptionsBare`,
219
- // / `GTRepositoryCloneOptionsCheckout `,
194
+ // / `GTRepositoryCloneCheckoutOptions `,
220
195
// / `GTRepositoryCloneOptionsCredentialProvider`,
221
196
// / `GTRepositoryCloneOptionsCloneLocal`,
222
197
// / `GTRepositoryCloneOptionsServerCertificateURL`
@@ -228,6 +203,9 @@ extern NSString * const GTRepositoryInitOptionsOriginURLString;
228
203
// / May be NULL.
229
204
// /
230
205
// / returns nil (and fills the error parameter) if an error occurred, or a GTRepository object if successful.
206
+ + (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;
207
+
208
+ // / Backward-compatible method that uses `GTRepositoryCloneOptionsCheckout`
231
209
+ (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;
232
210
233
211
// / Lookup objects in the repo by oid or sha1
@@ -483,34 +461,20 @@ extern NSString * const GTRepositoryInitOptionsOriginURLString;
483
461
// / Checkout a commit
484
462
// /
485
463
// / targetCommit - The commit to checkout. Must not be nil.
486
- // / strategy - The checkout strategy to use.
487
- // / notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
488
- // / to be called.
464
+ // / options - The checkout options to use. Can be nil.
489
465
// / error - The error if one occurred. Can be NULL.
490
- // / notifyBlock - The block to call back for notification handling. Can be nil.
491
- // / progressBlock - The block to call back for progress updates. Can be nil.
492
466
// /
493
467
// / Returns YES if operation was successful, NO otherwise
494
- - (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 ;
468
+ - (BOOL )checkoutCommit : (GTCommit *)targetCommit options : ( nullable GTCheckoutOptions *) options error : ( NSError **) error ;
495
469
496
470
// / Checkout a reference
497
471
// /
498
- // / targetCommit - The reference to checkout.
499
- // / strategy - The checkout strategy to use.
500
- // / notifyFlags - Flags that indicate which notifications should cause `notifyBlock`
501
- // / to be called.
502
- // / error - The error if one occurred. Can be NULL.
503
- // / notifyBlock - The block to call back for notification handling. Can be nil.
504
- // / progressBlock - The block to call back for progress updates. Can be nil.
472
+ // / targetReference - The reference to checkout. Must not be nil.
473
+ // / options - The checkout options to use. Can be nil.
474
+ // / error - The error if one occurred. Can be NULL.
505
475
// /
506
476
// / Returns YES if operation was successful, NO otherwise
507
- - (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;
508
-
509
- // / Convenience wrapper for checkoutCommit:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
510
- - (BOOL )checkoutCommit:(GTCommit *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
511
-
512
- // / Convenience wrapper for checkoutReference:strategy:notifyFlags:error:notifyBlock:progressBlock without notifications
513
- - (BOOL )checkoutReference:(GTReference *)target strategy:(GTCheckoutStrategyType)strategy error:(NSError **)error progressBlock:(nullable void (^)(NSString *path, NSUInteger completedSteps, NSUInteger totalSteps))progressBlock;
477
+ - (BOOL )checkoutReference : (GTReference *)targetReference options : (nullable GTCheckoutOptions *)options error : (NSError **)error ;
514
478
515
479
// / Flush the gitattributes cache.
516
480
- (void )flushAttributesCache ;
0 commit comments