summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-01-11 14:42:35 -0800
committerShawn Pearce <spearce@spearce.org>2013-01-11 14:52:13 -0800
commit912ef3da19c7bc1975805e1e3e9746baf479c2be (patch)
tree6d924ee09630d6ce14fb97e0f435b96a6559ba51
parent50eab4aa48377d628b2715a520378adab32221e0 (diff)
downloadjgit-912ef3da19c7bc1975805e1e3e9746baf479c2be.tar.gz
jgit-912ef3da19c7bc1975805e1e3e9746baf479c2be.zip
Accept '-' instead of space in enum config values
This is necessary because some versions of JGit containing the flawed c98abc9c0586c73ef7df4172644b7dd21c979e9d were used in the wild and wrote bad configuration files. We now must accept this value in addition to the preferred case. Change-Id: I3ed5451735658df6381532499130e5186805024a
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java6
2 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index 9197e29224..925976d300 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -290,7 +290,7 @@ public class ConfigTest {
c = parse("[s \"b\"]\n\tc = one two\n");
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO));
- c = parse("[s \"b\"]\n\tc = one two\n");
+ c = parse("[s \"b\"]\n\tc = one-two\n");
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO));
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
index 5f58ece185..f882d49ed1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -388,6 +388,12 @@ public class Config {
return defaultValue;
String n = value.replace(' ', '_');
+
+ // Because of c98abc9c0586c73ef7df4172644b7dd21c979e9d being used in
+ // the real world before its breakage was fully understood, we must
+ // also accept '-' as though it were ' '.
+ n = n.replace('-', '_');
+
T trueState = null;
T falseState = null;
for (T e : all) {