diff --git a/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java b/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java
index b0983b944769..4ff939ab4342 100644
--- a/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java
+++ b/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java
@@ -100,8 +100,12 @@ public class CherryPicker {
return false;
}
}
+ else if (localChangesOverwrittenDetector.hasHappened()) {
+ notifyError("Your local changes would be overwritten by cherry-pick.
Commit your changes or stash them to proceed.",
+ commit, successfulCommits);
+ return false;
+ }
else {
- // including localChangesOverwrittenDetector.hasHappened() - no special handler for now
notifyError(result.getErrorOutputAsHtmlString(), commit, successfulCommits);
return false;
}
@@ -112,7 +116,7 @@ public class CherryPicker {
private void notifyConflictWarning(GitCommit commit, List successfulCommits) {
String description = commitDetails(commit);
- description += getSuccessfulCommitDetailsIfAny(successfulCommits, description);
+ description += getSuccessfulCommitDetailsIfAny(successfulCommits);
myPlatformFacade.getNotificator(myProject).notifyWeakWarning("Cherry-picked with conflicts", description);
}
@@ -158,12 +162,13 @@ public class CherryPicker {
private void notifyError(@NotNull String content, @NotNull GitCommit failedCommit, @NotNull List successfulCommits) {
String description = "Cherry-pick failed for " + commitDetails(failedCommit) + "
" + content;
- description += getSuccessfulCommitDetailsIfAny(successfulCommits, description);
+ description += getSuccessfulCommitDetailsIfAny(successfulCommits);
myPlatformFacade.getNotificator(myProject).notifyError("Cherry-pick failed", description);
}
@NotNull
- private static String getSuccessfulCommitDetailsIfAny(@NotNull List successfulCommits, @NotNull String description) {
+ private static String getSuccessfulCommitDetailsIfAny(@NotNull List successfulCommits) {
+ String description = "";
if (!successfulCommits.isEmpty()) {
description += "
However it succeeded for the following " + StringUtil.pluralize("commit", successfulCommits.size()) + ":
";
description = getCommitsDetails(successfulCommits);
@@ -187,7 +192,7 @@ public class CherryPicker {
@NotNull
private static String commitDetails(@NotNull GitCommit commit) {
- return commit.getShortHash().toString() + " " + commit.getSubject();
+ return commit.getShortHash().toString() + " \"" + commit.getSubject() + "\"";
}
private void refreshChangedFiles(@NotNull Collection filePaths) {
diff --git a/plugins/git4idea/tests/git4idea/cherrypick/GitAutoCommittingCherryPickTest.groovy b/plugins/git4idea/tests/git4idea/cherrypick/GitAutoCommittingCherryPickTest.groovy
index c4344bc7d98b..36d8016909f2 100644
--- a/plugins/git4idea/tests/git4idea/cherrypick/GitAutoCommittingCherryPickTest.groovy
+++ b/plugins/git4idea/tests/git4idea/cherrypick/GitAutoCommittingCherryPickTest.groovy
@@ -15,7 +15,6 @@
*/
package git4idea.cherrypick
-import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import git4idea.history.browser.CherryPicker
import git4idea.history.browser.GitCommit
@@ -76,13 +75,15 @@ Otherwise, please use 'git reset'
void "dirty tree, conflicting with commit, then show error"() {
myGit.registerOperationExecutors(new SimpleErrorOperationExecutor(CHERRY_PICK, LOCAL_CHANGES_OVERWRITTEN_BY_CHERRY_PICK))
- invokeCherryPick(commit())
+ def commit = commit()
+ invokeCherryPick(commit)
assertNotCherryPicked()
assertOnlyDefaultChangelist()
- assertNotificationShown(new Notification(TEST_NOTIFICATION_GROUP, "Cherry-pick failed",
- "Your local changes to some files would be overwritten by cherry-pick. View them",
- NotificationType.ERROR))
+ assertNotificationShown("Cherry-pick failed",
+ "Cherry-pick failed for ${notificationContent(commit)}" +
+ "Your local changes would be overwritten by cherry-pick.
Commit your changes or stash them to proceed.",
+ NotificationType.ERROR)
}
@Test
diff --git a/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy b/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy
index a04d9ca80ff9..037ac382a7ef 100644
--- a/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy
+++ b/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy
@@ -119,7 +119,7 @@ hint: and commit the result with 'git commit'
}
String notificationContent(GitCommit commit) {
- "${commit.shortHash.toString()} ${commit.subject}"
+ "${commit.shortHash.toString()} \"${commit.subject}\""
}
String notificationContent(GitCommit... commits) {