aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
index d0d40c4679..e31f119cb2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
@@ -64,6 +64,8 @@ public class CleanCommand extends GitCommand<Set<String>> {
private Set<String> paths = Collections.emptySet();
+ private boolean dryRun;
+
/**
* @param repo
*/
@@ -86,7 +88,8 @@ public class CleanCommand extends GitCommand<Set<String>> {
Status status = command.call();
for (String file : status.getUntracked()) {
if (paths.isEmpty() || paths.contains(file)) {
- FileUtils.delete(new File(repo.getWorkTree(), file));
+ if (!dryRun)
+ FileUtils.delete(new File(repo.getWorkTree(), file));
files.add(file);
}
}
@@ -108,4 +111,15 @@ public class CleanCommand extends GitCommand<Set<String>> {
return this;
}
+ /**
+ * If dryRun is set, the paths in question will not actually be deleted.
+ *
+ * @param dryRun
+ * whether to do a dry run or not
+ * @return {@code this}
+ */
+ public CleanCommand setDryRun(boolean dryRun) {
+ this.dryRun = dryRun;
+ return this;
+ }
}