Skip to content
Merged
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
4 changes: 3 additions & 1 deletion GitUpKit/Views/GIMapViewController+Operations.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ - (void)swapCommitWithChild:(GCHistoryCommit*)commit {

- (void)squashCommitWithParent:(GCHistoryCommit*)commit {
if ([self checkCleanRepositoryForOperationOnCommit:commit]) {
[self _promptForCommitMessage:_CleanedUpCommitMessage(commit.message)
GCHistoryCommit* parentCommit = commit.parents.firstObject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the commit has no parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the GitUp UI, the "Squash With Parent" action is disabled when a commit does not have a parent. Outside of GitUp usage this of course result in an error but I believe there are other places that assume commit.parents will be non-null.

NSString* mergedMessage = [NSString stringWithFormat:NSLocalizedString(@"%@\n\n%@", nil), _CleanedUpCommitMessage(parentCommit.message), _CleanedUpCommitMessage(commit.message)];
[self _promptForCommitMessage:mergedMessage
withTitle:NSLocalizedString(@"Squashed commit message:", nil)
button:NSLocalizedString(@"Squash", nil)
block:^(NSString* message) {
Expand Down