|
|
@ -45,6 +45,8 @@ |
|
|
|
package org.eclipse.jgit.pgm; |
|
|
|
package org.eclipse.jgit.pgm; |
|
|
|
|
|
|
|
|
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.MessageFormat; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.api.CheckoutCommand; |
|
|
|
import org.eclipse.jgit.api.CheckoutCommand; |
|
|
|
import org.eclipse.jgit.api.Git; |
|
|
|
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.eclipse.jgit.pgm.internal.CLIText; |
|
|
|
import org.kohsuke.args4j.Argument; |
|
|
|
import org.kohsuke.args4j.Argument; |
|
|
|
import org.kohsuke.args4j.Option; |
|
|
|
import org.kohsuke.args4j.Option; |
|
|
|
|
|
|
|
import org.kohsuke.args4j.spi.StopOptionHandler; |
|
|
|
|
|
|
|
|
|
|
|
@Command(common = true, usage = "usage_checkout") |
|
|
|
@Command(common = true, usage = "usage_checkout") |
|
|
|
class Checkout extends TextBuiltin { |
|
|
|
class Checkout extends TextBuiltin { |
|
|
@ -68,9 +71,13 @@ class Checkout extends TextBuiltin { |
|
|
|
@Option(name = "--force", aliases = { "-f" }, usage = "usage_forceCheckout") |
|
|
|
@Option(name = "--force", aliases = { "-f" }, usage = "usage_forceCheckout") |
|
|
|
private boolean force = false; |
|
|
|
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; |
|
|
|
private String name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Argument(index = 1) |
|
|
|
|
|
|
|
@Option(name = "--", metaVar = "metaVar_paths", multiValued = true, handler = StopOptionHandler.class) |
|
|
|
|
|
|
|
private List<String> paths = new ArrayList<String>(); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void run() throws Exception { |
|
|
|
protected void run() throws Exception { |
|
|
|
if (createBranch) { |
|
|
|
if (createBranch) { |
|
|
@ -80,9 +87,15 @@ class Checkout extends TextBuiltin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CheckoutCommand command = new Git(db).checkout(); |
|
|
|
CheckoutCommand command = new Git(db).checkout(); |
|
|
|
|
|
|
|
if (paths.size() > 0) { |
|
|
|
|
|
|
|
command.setStartPoint(name); |
|
|
|
|
|
|
|
for (String path : paths) |
|
|
|
|
|
|
|
command.addPath(path); |
|
|
|
|
|
|
|
} else { |
|
|
|
command.setCreateBranch(createBranch); |
|
|
|
command.setCreateBranch(createBranch); |
|
|
|
command.setName(name); |
|
|
|
command.setName(name); |
|
|
|
command.setForce(force); |
|
|
|
command.setForce(force); |
|
|
|
|
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
String oldBranch = db.getBranch(); |
|
|
|
String oldBranch = db.getBranch(); |
|
|
|
Ref ref = command.call(); |
|
|
|
Ref ref = command.call(); |
|
|
|