Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2014-08-24 12:43:29 +0000
committerMatthias Sohn2014-12-12 23:14:15 +0000
commit8aa7103692227c281f2a3c046cf0bd0a2e8aec1f (patch)
tree5757188e8d56cfba7b0b1d3a8e22e7e1b3af8419 /org.eclipse.egit.core/src/org/eclipse/egit/core/op
parent5346986a7e4037a10e69edc5cad813fd3fdaaae1 (diff)
downloadegit-8aa7103692227c281f2a3c046cf0bd0a2e8aec1f.tar.gz
egit-8aa7103692227c281f2a3c046cf0bd0a2e8aec1f.tar.xz
egit-8aa7103692227c281f2a3c046cf0bd0a2e8aec1f.zip
Support checking out stage with DiscardChangesOperation
For resolving conflicts, we want to be able to do `git checkout --ours` or `git checkout --theirs` for a path. Change-Id: Ia6d003993ad1016602ff960203b3526cd884bad2 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core/src/org/eclipse/egit/core/op')
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java44
1 files changed, 43 insertions, 1 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java
index f40e59c44e..b5eeac661b 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/DiscardChangesOperation.java
@@ -50,6 +50,32 @@ public class DiscardChangesOperation implements IEGitOperation {
private String revision;
+ private Stage stage;
+
+ /**
+ * The index stage to check out for conflicting files.
+ */
+ public enum Stage {
+ /**
+ * "base" stage
+ */
+ BASE(CheckoutCommand.Stage.BASE),
+ /**
+ * "ours" stage
+ */
+ OURS(CheckoutCommand.Stage.OURS),
+ /**
+ * "theirs" stage
+ */
+ THEIRS(CheckoutCommand.Stage.THEIRS);
+
+ private CheckoutCommand.Stage checkoutStage;
+
+ private Stage(CheckoutCommand.Stage checkoutStage) {
+ this.checkoutStage = checkoutStage;
+ }
+ }
+
/**
* Construct a {@link DiscardChangesOperation} object.
*
@@ -86,6 +112,19 @@ public class DiscardChangesOperation implements IEGitOperation {
.keySet());
}
+ /**
+ * Set the index stage to check out for conflicting files. Not compatible
+ * with revision.
+ *
+ * @param stage
+ */
+ public void setStage(Stage stage) {
+ if (revision != null)
+ throw new IllegalStateException(
+ "Either stage or revision can be set, but not both"); //$NON-NLS-1$
+ this.stage = stage;
+ }
+
/*
* (non-Javadoc)
*
@@ -151,7 +190,10 @@ public class DiscardChangesOperation implements IEGitOperation {
throws GitAPIException {
ResourceUtil.saveLocalHistory(repository);
CheckoutCommand checkoutCommand = new Git(repository).checkout();
- checkoutCommand.setStartPoint(this.revision);
+ if (revision != null)
+ checkoutCommand.setStartPoint(revision);
+ if (stage != null)
+ checkoutCommand.setStage(stage.checkoutStage);
if (paths.isEmpty() || paths.contains("")) //$NON-NLS-1$
checkoutCommand.setAllPaths(true);
else {

Back to the top