summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2016-10-22 10:11:54 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2016-10-22 10:11:54 +0900
commit03046d0f60810ec01d830e6efb3291e4a161512a (patch)
tree45c5213bb43e7f0e8f265457cb6e5e47daae512e
parente49025386eee85f4748b3f16ae2c63f6ff94f335 (diff)
downloadjgit-03046d0f60810ec01d830e6efb3291e4a161512a.tar.gz
jgit-03046d0f60810ec01d830e6efb3291e4a161512a.zip
CheckoutCommand: Add method to add multiple paths
The new method addPaths(List<String>) allows callers to add multiple paths without having to iterate over several calls to addPath(String). Change-Id: I2c3746a97ead7118fb0ed5543a2c843224719031 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java20
2 files changed, 21 insertions, 3 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 629b47a9a0..0c3b720fb6 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
@@ -95,9 +95,7 @@ class Checkout extends TextBuiltin {
if (paths.size() == 1 && paths.get(0).equals(".")) { //$NON-NLS-1$
command.setAllPaths(true);
} else {
- for (String path : paths) {
- command.addPath(path);
- }
+ command.addPaths(paths);
}
} else {
command.setCreateBranch(createBranch);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
index 20d0704509..c17ae5c00d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
@@ -367,6 +367,26 @@ public class CheckoutCommand extends GitCommand<Ref> {
}
/**
+ * Add multiple slash-separated paths to the list of paths to check out. To
+ * check out all paths, use {@link #setAllPaths(boolean)}.
+ * <p>
+ * If this option is set, neither the {@link #setCreateBranch(boolean)} nor
+ * {@link #setName(String)} option is considered. In other words, these
+ * options are exclusive.
+ *
+ * @param p
+ * paths to update in the working tree and index (with
+ * <code>/</code> as separator)
+ * @return {@code this}
+ * @since 4.6
+ */
+ public CheckoutCommand addPaths(List<String> p) {
+ checkCallable();
+ this.paths.addAll(p);
+ return this;
+ }
+
+ /**
* Set whether to checkout all paths.
* <p>
* This options should be used when you want to do a path checkout on the