aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2014-02-10 08:10:31 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2014-05-12 17:12:48 -0400
commitbbf28b1cf4c7a6e2d4fdafd31b79777251d20094 (patch)
tree3f68dd0b6535b5755398f20f482d9c1c56e6deee /org.eclipse.jgit.pgm
parentb13907f0869141b1a1342b33de35e515fe8ce124 (diff)
downloadjgit-bbf28b1cf4c7a6e2d4fdafd31b79777251d20094.tar.gz
jgit-bbf28b1cf4c7a6e2d4fdafd31b79777251d20094.zip
Command line: implement checkout -- <path>
Change-Id: I3d261e6541fe0fcaa210587d2aa226e153071351 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
index 2f35ecbabd..8f911fd924 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
@@ -45,6 +45,8 @@
package org.eclipse.jgit.pgm;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jgit.api.CheckoutCommand;
import org.eclipse.jgit.api.Git;
@@ -58,6 +60,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
+import org.kohsuke.args4j.spi.StopOptionHandler;
@Command(common = true, usage = "usage_checkout")
class Checkout extends TextBuiltin {
@@ -68,9 +71,13 @@ class Checkout extends TextBuiltin {
@Option(name = "--force", aliases = { "-f" }, usage = "usage_forceCheckout")
private boolean force = false;
- @Argument(required = true, metaVar = "metaVar_name", usage = "usage_checkout")
+ @Argument(required = true, index = 0, metaVar = "metaVar_name", usage = "usage_checkout")
private String name;
+ @Argument(index = 1)
+ @Option(name = "--", metaVar = "metaVar_paths", multiValued = true, handler = StopOptionHandler.class)
+ private List<String> paths = new ArrayList<String>();
+
@Override
protected void run() throws Exception {
if (createBranch) {
@@ -80,9 +87,15 @@ class Checkout extends TextBuiltin {
}
CheckoutCommand command = new Git(db).checkout();
- command.setCreateBranch(createBranch);
- command.setName(name);
- command.setForce(force);
+ if (paths.size() > 0) {
+ command.setStartPoint(name);
+ for (String path : paths)
+ command.addPath(path);
+ } else {
+ command.setCreateBranch(createBranch);
+ command.setName(name);
+ command.setForce(force);
+ }
try {
String oldBranch = db.getBranch();
Ref ref = command.call();