aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
diff options
context:
space:
mode:
authorAbhishek Bhatnagar <abhatnag@redhat.com>2011-05-24 14:45:05 -0400
committerChris Aniszczyk <caniszczyk@gmail.com>2011-05-24 17:32:19 -0500
commit7d380e9c5e1602e0938792869c4fcba88fd0dc2f (patch)
tree7fb24a07054d11aee484da05be7213b2511b9c9b /org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
parent08f0e1ffed11012e5069945eb730d44f0adbcd68 (diff)
downloadjgit-7d380e9c5e1602e0938792869c4fcba88fd0dc2f.tar.gz
jgit-7d380e9c5e1602e0938792869c4fcba88fd0dc2f.zip
Add CleanCommandTest and fix CleanCommand
Bug: 334767 Change-Id: I0a836451ceb668f943b1f353dc65420157810b23 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java11
1 files changed, 6 insertions, 5 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 a3c8e5c939..d0d40c4679 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
@@ -47,6 +47,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.lib.Repository;
@@ -79,15 +80,15 @@ public class CleanCommand extends GitCommand<Set<String>> {
* @return a set of strings representing each file cleaned.
*/
public Set<String> call() {
- Set<String> files = Collections.emptySet();
+ Set<String> files = new TreeSet<String>();
try {
StatusCommand command = new StatusCommand(repo);
Status status = command.call();
- files = status.getUntracked();
-
- for (String file : files) {
- if (paths.isEmpty() || paths.contains(file))
+ for (String file : status.getUntracked()) {
+ if (paths.isEmpty() || paths.contains(file)) {
FileUtils.delete(new File(repo.getWorkTree(), file));
+ files.add(file);
+ }
}
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);