Browse Source

Merge "Revert "Config: Distinguish between empty and null strings""

stable-4.1
Jonathan Nieder 10 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
e75bc4321a
  1. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java

@ -707,8 +707,8 @@ public class ConfigTest {
assertEquals("0", c.getString("a", null, "x")); assertEquals("0", c.getString("a", null, "x"));
assertEquals(0, c.getInt("a", null, "x", 1)); assertEquals(0, c.getInt("a", null, "x", 1));
assertEquals("", c.getString("a", null, "y")); assertNull(c.getString("a", null, "y"));
assertArrayEquals(new String[]{""}, c.getStringList("a", null, "y")); assertArrayEquals(new String[]{null}, c.getStringList("a", null, "y"));
try { try {
c.getInt("a", null, "y", 1); c.getInt("a", null, "y", 1);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -730,9 +730,13 @@ public class ConfigTest {
public void testEmptyValueAtEof() throws Exception { public void testEmptyValueAtEof() throws Exception {
String text = "[a]\nx ="; String text = "[a]\nx =";
Config c = parse(text); Config c = parse(text);
assertEquals("", c.getString("a", null, "x")); assertNull(c.getString("a", null, "x"));
assertArrayEquals(new String[]{null},
c.getStringList("a", null, "x"));
c = parse(text + "\n"); c = parse(text + "\n");
assertEquals("", c.getString("a", null, "x")); assertNull(c.getString("a", null, "x"));
assertArrayEquals(new String[]{null},
c.getStringList("a", null, "x"));
} }
private static void assertReadLong(long exp) throws ConfigInvalidException { private static void assertReadLong(long exp) throws ConfigInvalidException {

2
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

@ -1266,7 +1266,7 @@ public class Config {
value.append((char) c); value.append((char) c);
} }
return value.toString(); return value.length() > 0 ? value.toString() : null;
} }
/** /**

Loading…
Cancel
Save