Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix untracked files problem in multiple commits rebases with conflicts #990

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion GitUpKit/Core/GCRepository+HEAD.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

typedef NS_OPTIONS(NSUInteger, GCCheckoutOptions) {
kGCCheckoutOption_Force = (1 << 0),
kGCCheckoutOption_UpdateSubmodulesRecursively = (1 << 1)
kGCCheckoutOption_UpdateSubmodulesRecursively = (1 << 1),
kGCCheckoutOption_RemoveUntrackedFiles = (1 << 2),
};

@interface GCRepository (HEAD)
Expand Down
5 changes: 5 additions & 0 deletions GitUpKit/Core/GCRepository+HEAD.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ - (BOOL)_checkoutTreeForCommit:(GCCommit*)commit
git_tree* tree = NULL;
git_checkout_options checkoutOptions = GIT_CHECKOUT_OPTIONS_INIT;
checkoutOptions.checkout_strategy = options & kGCCheckoutOption_Force ? GIT_CHECKOUT_FORCE : GIT_CHECKOUT_SAFE;

if (options & kGCCheckoutOption_RemoveUntrackedFiles) {
checkoutOptions.checkout_strategy |= GIT_CHECKOUT_REMOVE_UNTRACKED;
}

if (baseline) {
CALL_LIBGIT2_FUNCTION_RETURN(NO, git_commit_tree, &tree, baseline.private);
checkoutOptions.baseline = tree;
Expand Down
2 changes: 1 addition & 1 deletion GitUpKit/Extensions/GCRepository+Utilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ - (BOOL)forceCheckoutHEAD:(BOOL)recursive error:(NSError**)error {
if (![self lookupHEADCurrentCommit:&headCommit branch:NULL error:error]) {
return NO;
}
GCCheckoutOptions options = kGCCheckoutOption_Force;
GCCheckoutOptions options = kGCCheckoutOption_Force | kGCCheckoutOption_RemoveUntrackedFiles;
if (recursive) {
options |= kGCCheckoutOption_UpdateSubmodulesRecursively;
}
Expand Down