8000 Add checkout options support to stash API. · libgit2/objective-git@84fd119 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 84fd119

Browse files
committed
Add checkout options support to stash API.
1 parent f66d713 commit 84fd119

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

ObjectiveGit/GTRepository+Stashing.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,23 @@ NS_ASSUME_NONNULL_BEGIN
6666
///
6767
/// index - The index of the stash to apply. 0 is the latest one.
6868
/// flags - The flags to use when applying the stash.
69+
/// options - The options to use when checking out.
6970
/// error - If not NULL, set to any error that occurred.
7071
/// progressBlock - A block that will be executed on each step of the stash application.
7172
///
7273
/// Returns YES if the requested stash was successfully applied, NO otherwise.
73-
- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock;
74+
- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(nullable GTCheckoutOptions *)options error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock;
7475

7576
/// Pop stashed changes.
7677
///
7778
/// index - The index of the stash to apply. 0 is the most recent stash.
7879
/// flags - The flags to use when applying the stash.
80+
/// options - The options to use when checking out.
7981
/// error - If not NULL, set to any error that occurred.
8082
/// progressBlock - A block that will be executed on each step of the stash application.
8183
///
8284
/// Returns YES if the requested stash was successfully applied, NO otherwise.
83-
- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock;
85+
- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(nullable GTCheckoutOptions *)options error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock;
8486

8587
/// Drop a stash from the repository's list of stashes.
8688
///

ObjectiveGit/GTRepository+Stashing.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int stashApplyProgressCallback(git_stash_apply_progress_t progress, void
5959
return (stop ? GIT_EUSER : 0);
6060
}
6161

62-
- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock {
62+
- (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions *)options error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock {
6363
git_stash_apply_options stash_options = GIT_STASH_APPLY_OPTIONS_INIT;
6464

6565
stash_options.flags = (git_stash_apply_flags)flags;
@@ -68,6 +68,10 @@ - (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)fl
6868
stash_options.progress_payload = (__bridge void *)progressBlock;
6969
}
7070

71+
if (options != nil) {
72+
stash_options.checkout_options = *options.git_checkoutOptions;
73+
}
74+
7175
int gitError = git_stash_apply(self.git_repository, index, &stash_options);
7276
if (gitError != GIT_OK) {
7377
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Stash apply failed" failureReason:@"The stash at index %ld couldn't be applied.", (unsigned long)index];
@@ -76,7 +80,7 @@ - (BOOL)applyStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)fl
7680
return YES;
7781
}
7882

79-
- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock {
83+
- (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flags checkoutOptions:(GTCheckoutOptions *)options error:(NSError **)error progressBlock:(nullable void (^)(GTRepositoryStashApplyProgress progress, BOOL *stop))progressBlock{
8084
git_stash_apply_options stash_options = GIT_STASH_APPLY_OPTIONS_INIT;
8185

8286
stash_options.flags = (git_stash_apply_flags)flags;
@@ -85,6 +89,10 @@ - (BOOL)popStashAtIndex:(NSUInteger)index flags:(GTRepositoryStashApplyFlag)flag
8589
stash_options.progress_payload = (__bridge void *)progressBlock;
8690
}
8791

92+
if (options != nil) {
93+
stash_options.checkout_options = *options.git_checkoutOptions;
94+
}
95+
8896
int gitError = git_stash_pop(self.git_repository, index, &stash_options);
8997
if (gitError != GIT_OK) {
9098
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Stash pop failed" failureReason:@"The stash at index %ld couldn't be applied.", (unsigned long)index];

0 commit comments

Comments
 (0)
0