Browse Source

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>
stable-4.6
David Pursehouse 8 years ago
parent
commit
03046d0f60
  1. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
  2. 20
      org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java

4
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);

20
org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java

@ -366,6 +366,26 @@ public class CheckoutCommand extends GitCommand<Ref> {
return this;
}
/**
* 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>

Loading…
Cancel
Save