git: unstash local changes if user cancels interactive rebase dialog: IDEA-156454

This commit is contained in:
Kirill Likhodedov
2018-06-20 18:25:37 +03:00
parent 90dad0d96e
commit 05131fec8d
@@ -130,7 +130,7 @@ public class GitRebaseProcess {
try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(myProject, "Rebase")) { try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(myProject, "Rebase")) {
if (!saveDirtyRootsInitially(repositoriesToRebase)) return; if (!saveDirtyRootsInitially(repositoriesToRebase)) return;
GitRepository failed = null; GitRepository latestRepository = null;
for (GitRepository repository : repositoriesToRebase) { for (GitRepository repository : repositoriesToRebase) {
GitRebaseResumeMode customMode = null; GitRebaseResumeMode customMode = null;
if (repository == myRebaseSpec.getOngoingRebase()) { if (repository == myRebaseSpec.getOngoingRebase()) {
@@ -144,21 +144,23 @@ public class GitRebaseProcess {
if (customMode == GitRebaseResumeMode.CONTINUE) { if (customMode == GitRebaseResumeMode.CONTINUE) {
myDirtyScopeManager.dirDirtyRecursively(repository.getRoot()); myDirtyScopeManager.dirDirtyRecursively(repository.getRoot());
} }
latestRepository = repository;
statuses.put(repository, rebaseStatus); statuses.put(repository, rebaseStatus);
if (shouldBeRefreshed(rebaseStatus)) { if (shouldBeRefreshed(rebaseStatus)) {
refreshVfs(repository.getRoot(), changes); refreshVfs(repository.getRoot(), changes);
} }
if (rebaseStatus.getType() != GitRebaseStatus.Type.SUCCESS) { if (rebaseStatus.getType() != GitRebaseStatus.Type.SUCCESS) {
failed = repository;
break; break;
} }
} }
if (failed == null) { GitRebaseStatus.Type latestStatus = statuses.get(latestRepository).getType();
if (latestStatus == GitRebaseStatus.Type.SUCCESS || latestStatus == GitRebaseStatus.Type.NOT_STARTED) {
LOG.debug("Rebase completed successfully."); LOG.debug("Rebase completed successfully.");
mySaver.load(); mySaver.load();
} }
if (failed == null) { if (latestStatus == GitRebaseStatus.Type.SUCCESS) {
notifySuccess(getSuccessfulRepositories(statuses), getSkippedCommits(statuses)); notifySuccess(getSuccessfulRepositories(statuses), getSkippedCommits(statuses));
} }
@@ -227,8 +229,7 @@ public class GitRebaseProcess {
boolean somethingRebased = customMode != null || progressListener.currentCommit > 1; boolean somethingRebased = customMode != null || progressListener.currentCommit > 1;
if (rebaseCommandResult.wasCancelledInCommitList()) { if (rebaseCommandResult.wasCancelledInCommitList()) {
LOG.info("Rebase was cancelled"); return GitRebaseStatus.notStarted();
throw new ProcessCanceledException();
} }
else if (rebaseCommandResult.wasCancelledInCommitMessage()) { else if (rebaseCommandResult.wasCancelledInCommitMessage()) {
showStoppedForEditingMessage(); showStoppedForEditingMessage();