Browse Source

Merge "Preserve backslashes within double quotes in CLIGitCommand::split()"

tags/v4.6.0.201612231935-r
David Pursehouse 7 years ago
parent
commit
88f433be84

+ 1
- 1
org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java View File

inquote = !inquote; inquote = !inquote;
continue; continue;
case '\\': case '\\':
if (inquote || ip == commandLine.length())
if (inDblQuote || inquote || ip == commandLine.length())
r.append(b); // literal within a quote r.append(b); // literal within a quote
else else
r.append(commandLine.charAt(ip++)); r.append(commandLine.charAt(ip++));

+ 2
- 0
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CLIGitCommandTest.java View File



@Test @Test
public void testSplit() throws Exception { public void testSplit() throws Exception {
assertArrayEquals(new String[0], split(""));
assertArrayEquals(new String[] { "a" }, split("a")); assertArrayEquals(new String[] { "a" }, split("a"));
assertArrayEquals(new String[] { "a", "b" }, split("a b")); assertArrayEquals(new String[] { "a", "b" }, split("a b"));
assertArrayEquals(new String[] { "a", "b c" }, split("a 'b c'")); assertArrayEquals(new String[] { "a", "b c" }, split("a 'b c'"));
assertArrayEquals(new String[] { "a", "b c" }, split("a \"b c\"")); assertArrayEquals(new String[] { "a", "b c" }, split("a \"b c\""));
assertArrayEquals(new String[] { "a", "b\\c" }, split("a \"b\\c\""));
} }
} }

Loading…
Cancel
Save