diff options
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java | 16 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java | 71 |
2 files changed, 50 insertions, 37 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; + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java index 8fe7b2aa51..8534724cbb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java @@ -202,43 +202,42 @@ public class URIish implements Serializable { if (matcher.matches()) { scheme = matcher.group(1); path = cleanLeadingSlashes(matcher.group(2), scheme); - } else { - matcher = FULL_URI.matcher(s); - if (matcher.matches()) { - scheme = matcher.group(1); - user = matcher.group(2); - pass = matcher.group(3); - host = matcher.group(4); - if (matcher.group(5) != null) - port = Integer.parseInt(matcher.group(5)); - path = cleanLeadingSlashes( - n2e(matcher.group(6)) + n2e(matcher.group(7)), - scheme); - } else { - matcher = RELATIVE_SCP_URI.matcher(s); - if (matcher.matches()) { - user = matcher.group(1); - pass = matcher.group(2); - host = matcher.group(3); - path = matcher.group(4); - } else { - matcher = ABSOLUTE_SCP_URI.matcher(s); - if (matcher.matches()) { - user = matcher.group(1); - pass = matcher.group(2); - host = matcher.group(3); - path = matcher.group(4); - } else { - matcher = LOCAL_FILE.matcher(s); - if (matcher.matches()) { - path = matcher.group(1); - } else - throw new URISyntaxException(s, - JGitText.get().cannotParseGitURIish); - } - } - } + return; + } + matcher = FULL_URI.matcher(s); + if (matcher.matches()) { + scheme = matcher.group(1); + user = matcher.group(2); + pass = matcher.group(3); + host = matcher.group(4); + if (matcher.group(5) != null) + port = Integer.parseInt(matcher.group(5)); + path = cleanLeadingSlashes( + n2e(matcher.group(6)) + n2e(matcher.group(7)), scheme); + return; + } + matcher = RELATIVE_SCP_URI.matcher(s); + if (matcher.matches()) { + user = matcher.group(1); + pass = matcher.group(2); + host = matcher.group(3); + path = matcher.group(4); + return; + } + matcher = ABSOLUTE_SCP_URI.matcher(s); + if (matcher.matches()) { + user = matcher.group(1); + pass = matcher.group(2); + host = matcher.group(3); + path = matcher.group(4); + return; + } + matcher = LOCAL_FILE.matcher(s); + if (matcher.matches()) { + path = matcher.group(1); + return; } + throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish); } private String n2e(String s) { |