aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/diff
diff options
context:
space:
mode:
authorMarc Strapetz <marc.strapetz@syntevo.com>2010-11-26 11:07:04 +0100
committerMarc Strapetz <marc.strapetz@syntevo.com>2010-11-29 17:14:07 +0100
commite147fbcd6646f1746073d4d6b8f07ab1ee41b08c (patch)
tree7caaa07e90c8b324161e7e4a2fcbf1bee1af2733 /org.eclipse.jgit/src/org/eclipse/jgit/diff
parent7e298c9ed538dd8d5207adce3497b4a1df701dc5 (diff)
downloadjgit-e147fbcd6646f1746073d4d6b8f07ab1ee41b08c.tar.gz
jgit-e147fbcd6646f1746073d4d6b8f07ab1ee41b08c.zip
Fix DiffConfig to understand "copy" resp. "copies" for diff.renames property.
Rename detection should be considered enabled if diff.renames config property is set to "copy" or "copies", instead of throwing IllegalArgumentException. Change-Id: If55d955e37235d4d00f5b0febd6aa10c0e27814e
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/diff')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java49
1 files changed, 46 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java
index 4b86f55fcd..436e606ad5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java
@@ -43,8 +43,12 @@
package org.eclipse.jgit.diff;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Config.SectionParser;
+import org.eclipse.jgit.util.StringUtils;
/** Keeps track of diff related configuration options. */
public class DiffConfig {
@@ -55,15 +59,28 @@ public class DiffConfig {
}
};
+ /** Permissible values for {@code diff.renames}. */
+ public static enum RenameDetectionType {
+ /** Rename detection is disabled. */
+ FALSE,
+
+ /** Rename detection is enabled. */
+ TRUE,
+
+ /** Copies should be detected too. */
+ COPY
+ }
+
private final boolean noPrefix;
- private final boolean renames;
+ private final RenameDetectionType renameDetectionType;
private final int renameLimit;
private DiffConfig(final Config rc) {
noPrefix = rc.getBoolean("diff", "noprefix", false);
- renames = rc.getBoolean("diff", "renames", false);
+ renameDetectionType = parseRenameDetectionType(rc.getString("diff",
+ null, "renames"));
renameLimit = rc.getInt("diff", "renamelimit", 200);
}
@@ -74,11 +91,37 @@ public class DiffConfig {
/** @return true if rename detection is enabled by default. */
public boolean isRenameDetectionEnabled() {
- return renames;
+ return renameDetectionType != RenameDetectionType.FALSE;
+ }
+
+ /** @return type of rename detection to perform. */
+ public RenameDetectionType getRenameDetectionType() {
+ return renameDetectionType;
}
/** @return limit on number of paths to perform inexact rename detection. */
public int getRenameLimit() {
return renameLimit;
}
+
+ private static RenameDetectionType parseRenameDetectionType(
+ final String renameString) {
+ if (renameString == null)
+ return RenameDetectionType.FALSE;
+ else if (StringUtils.equalsIgnoreCase("copy", renameString)
+ || StringUtils.equalsIgnoreCase("copies", renameString))
+ return RenameDetectionType.COPY;
+ else {
+ final Boolean renameBoolean = StringUtils
+ .toBooleanOrNull(renameString);
+ if (renameBoolean == null)
+ throw new IllegalArgumentException(MessageFormat.format(
+ JGitText.get().enumValueNotSupported2, "diff",
+ "renames", renameString));
+ else if (renameBoolean.booleanValue())
+ return RenameDetectionType.TRUE;
+ else
+ return RenameDetectionType.FALSE;
+ }
+ }
}