diff --git a/plugins/git4idea/src/git4idea/actions/GitUnstash.java b/plugins/git4idea/src/git4idea/actions/GitUnstash.java index 0715c8b46e45..2eb28c6caf2a 100644 --- a/plugins/git4idea/src/git4idea/actions/GitUnstash.java +++ b/plugins/git4idea/src/git4idea/actions/GitUnstash.java @@ -20,7 +20,6 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.VirtualFile; import git4idea.i18n.GitBundle; -import git4idea.repo.GitRepositoryManager; import git4idea.ui.GitUnstashDialog; import org.jetbrains.annotations.NotNull; @@ -50,6 +49,11 @@ public class GitUnstash extends GitRepositoryAction { final List exceptions) throws VcsException { final ChangeListManager changeListManager = ChangeListManager.getInstance(project); if (changeListManager.isFreezedWithNotification("Can not unstash changes now")) return; - GitUnstashDialog.showUnstashDialog(project, gitRoots, defaultRoot, affectedRoots); + GitUnstashDialog.showUnstashDialog(project, gitRoots, defaultRoot); + } + + @Override + protected boolean executeFinalTasksSynchronously() { + return false; } } diff --git a/plugins/git4idea/src/git4idea/commands/GitHandlerUtil.java b/plugins/git4idea/src/git4idea/commands/GitHandlerUtil.java index 05b8246dd7ab..03cfab25bc84 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHandlerUtil.java +++ b/plugins/git4idea/src/git4idea/commands/GitHandlerUtil.java @@ -372,12 +372,6 @@ public class GitHandlerUtil { } } } - /** - * Error indicators for the line - */ - @NonNls private static final String[] ERROR_INDICATORS = - {"ERROR:", "error", "FATAL:", "fatal", "Cannot apply", "Could not", "Interactive rebase already started", "refusing to pull", - "cannot rebase:"}; /** * Check if the line is an error line @@ -386,7 +380,7 @@ public class GitHandlerUtil { * @return true if the error line */ protected static boolean isErrorLine(String text) { - for (String prefix : ERROR_INDICATORS) { + for (String prefix : GitImpl.ERROR_INDICATORS) { if (text.startsWith(prefix)) { return true; } diff --git a/plugins/git4idea/src/git4idea/commands/GitImpl.java b/plugins/git4idea/src/git4idea/commands/GitImpl.java index 9f9eeae22688..29d6be84a3cb 100644 --- a/plugins/git4idea/src/git4idea/commands/GitImpl.java +++ b/plugins/git4idea/src/git4idea/commands/GitImpl.java @@ -339,14 +339,14 @@ public class GitImpl implements Git { } } - private GitCommandResult run(@NotNull GitLineHandler handler) { + private static GitCommandResult run(@NotNull GitLineHandler handler) { return run(handler, false); } /** * Runs the given {@link GitLineHandler} in the current thread and returns the {@link GitCommandResult}. */ - private GitCommandResult run(@NotNull GitLineHandler handler, boolean remote) { + private static GitCommandResult run(@NotNull GitLineHandler handler, boolean remote) { handler.setNoSSH(!remote); final List errorOutput = new ArrayList(); @@ -387,7 +387,7 @@ public class GitImpl implements Git { /** * Check if the line looks line an error message */ - private boolean isError(String text) { + private static boolean isError(String text) { for (String indicator : ERROR_INDICATORS) { if (text.startsWith(indicator.toLowerCase())) { return true; @@ -397,8 +397,9 @@ public class GitImpl implements Git { } // could be upper-cased, so should check case-insensitively - private final String[] ERROR_INDICATORS = { - "error", "fatal", "Cannot apply", "Could not", "Interactive rebase already started", "refusing to pull", "cannot rebase:", "conflict" + public static final String[] ERROR_INDICATORS = { + "error", "fatal", "Cannot apply", "Could not", "Interactive rebase already started", "refusing to pull", "cannot rebase:", "conflict", + "unable" }; } diff --git a/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java b/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java index 48bb90ea6839..8a5286351c3d 100644 --- a/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java +++ b/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java @@ -99,7 +99,7 @@ public class GitStashChangesSaver extends GitChangesSaver { @Override protected void showSavedChanges() { - GitUnstashDialog.showUnstashDialog(myProject, new ArrayList(myStashedRoots), myStashedRoots.iterator().next(), new HashSet()); + GitUnstashDialog.showUnstashDialog(myProject, new ArrayList(myStashedRoots), myStashedRoots.iterator().next()); } @Override @@ -216,8 +216,8 @@ public class GitStashChangesSaver extends GitChangesSaver { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (event.getDescription().equals("saver")) { // we don't use #showSavedChanges to specify unmerged root first - GitUnstashDialog.showUnstashDialog(myProject, new ArrayList(myStashedRoots), myStashedRoots.iterator().next(), - new HashSet()); + GitUnstashDialog.showUnstashDialog(myProject, new ArrayList(myStashedRoots), myStashedRoots.iterator().next() + ); } else if (event.getDescription().equals("resolve")) { mergeNoProceed(); } diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java index bf3d7793306b..df7051f224de 100644 --- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java @@ -390,26 +390,10 @@ public class GitUnstashDialog extends DialogWrapper { return myStashList; } - /** - * Show unstash dialog and process its result - * - * @param project the context project - * @param gitRoots the git roots - * @param defaultRoot the default git root - * @param affectedRoots the affected roots - */ - public static void showUnstashDialog(Project project, - List gitRoots, - VirtualFile defaultRoot, - Set affectedRoots) { - GitUnstashDialog d = new GitUnstashDialog(project, gitRoots, defaultRoot); - d.show(); - if (!d.isOK()) { - return; - } - VirtualFile root = d.getGitRoot(); - affectedRoots.add(root); - GitLineHandler h = d.handler(); + @Override + protected void doOKAction() { + VirtualFile root = getGitRoot(); + GitLineHandler h = handler(); final AtomicBoolean conflict = new AtomicBoolean(); h.addLineListener(new GitLineHandlerAdapter() { @@ -423,11 +407,17 @@ public class GitUnstashDialog extends DialogWrapper { root.refresh(true, true); if (conflict.get()) { - boolean conflictsResolved = new UnstashConflictResolver(project, root, d.getSelectedStash()).merge(); + boolean conflictsResolved = new UnstashConflictResolver(myProject, root, getSelectedStash()).merge(); LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved); } else if (rc != 0) { - GitUIUtil.showOperationErrors(project, h.errors(), h.printableCommandLine()); + GitUIUtil.showOperationErrors(myProject, h.errors(), h.printableCommandLine()); } + super.doOKAction(); + } + + public static void showUnstashDialog(Project project, List gitRoots, VirtualFile defaultRoot) { + new GitUnstashDialog(project, gitRoots, defaultRoot).show(); + // d is not modal=> everything else in doOKAction. } private static class UnstashConflictResolver extends GitConflictResolver {