Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2013-08-29 15:18:20 +0000
committerMatthias Sohn2013-08-30 13:13:57 +0000
commitebcf1b71b4cdcd3a707588484d2d426c7153ada3 (patch)
tree39f86078c0bc3c424c1bc7172f1eeb5828ca97ec
parenteadb08030191df2c09a9b712e12143a5f8f8209e (diff)
downloadegit-ebcf1b71b4cdcd3a707588484d2d426c7153ada3.tar.gz
egit-ebcf1b71b4cdcd3a707588484d2d426c7153ada3.tar.xz
egit-ebcf1b71b4cdcd3a707588484d2d426c7153ada3.zip
[historyView] Prevent nested rebase
Disable rebase when repository is not in a safe state. This prevents calling rebase when there is already a rebase, merge or cherry-pick in progress. Also safeguard against broken handlers which may miss to become disabled when not in a safe repository state in order to prevent that nested rebase gets aborted since this could destroy the work done while resolving conflicts in the first rebase. Throw an IllegalStateException in this case. Bug: 416136 Change-Id: I05054b6c7f6a49f4cd01d70ee44791e6985e9ee5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseHelper.java8
2 files changed, 17 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java
index 68995c867d..3e4e99f1d7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/RebaseCurrentHandler.java
@@ -23,8 +23,9 @@ import org.eclipse.jgit.lib.BranchConfig;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Ref.Storage;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.osgi.util.NLS;
@@ -33,6 +34,14 @@ import org.eclipse.osgi.util.NLS;
*/
public class RebaseCurrentHandler extends AbstractHistoryCommandHandler {
+ @Override
+ public boolean isEnabled() {
+ final Repository repository = getRepository(getPage());
+ if (repository == null)
+ return false;
+ return repository.getRepositoryState().equals(RepositoryState.SAFE);
+ }
+
public Object execute(ExecutionEvent event) throws ExecutionException {
PlotCommit commit = (PlotCommit) getSelection(getPage()).getFirstElement();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseHelper.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseHelper.java
index c35b0695c6..f3affa7260 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseHelper.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/rebase/RebaseHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
+ * Copyright (c) 2010, 2013 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -54,6 +54,12 @@ public class RebaseHelper {
Job job = new Job(jobname) {
@Override
protected IStatus run(IProgressMonitor monitor) {
+ // safeguard against broken handlers which don't check that
+ // repository state is safe
+ if (!repository.getRepositoryState().equals(
+ RepositoryState.SAFE))
+ throw new IllegalStateException(
+ "Can't start rebase if repository state isn't SAFE"); //$NON-NLS-1$
try {
rebase.execute(monitor);
} catch (final CoreException e) {

Back to the top