diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2020-05-26 08:50:33 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2020-05-28 12:06:57 +0200 |
commit | 6f17f9ed3fdadec1e6995f42ca34f570c0dee1b5 (patch) | |
tree | f526071a149a898828eaa79734c1ed5feb51c2a5 /org.eclipse.jgit.test | |
parent | 5a5d85a4a3407df5f9693ab36287e72726c512f6 (diff) | |
download | jgit-6f17f9ed3fdadec1e6995f42ca34f570c0dee1b5.tar.gz jgit-6f17f9ed3fdadec1e6995f42ca34f570c0dee1b5.zip |
RawTextComparator.WS_IGNORE_CHANGE must not compare whitespace
Only the presence or absence of whitespace is significant; but not the
actual whitespace characters. Don't compare whitespace bytes.
Compare the C git implementation at [1].
[1] https://github.com/git/git/blob/0d0e1e8/xdiff/xutils.c#L173
Bug: 563570
Change-Id: I2d0522b637ba6b5c8b911b3376a9df5daa9d4c27
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java index b271a048a4..73b2a72ace 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java @@ -75,4 +75,32 @@ public class RawTextIgnoreWhitespaceChangeTest { assertTrue(cmp.equals(a, 5, b, 5)); assertTrue(cmp.equals(b, 5, a, 5)); } + + @Test + public void testEqualsWithTabs() { + RawText a = new RawText( + Constants.encodeASCII("a\tb\t \na\tb\t c \n foo\na b\na b")); + RawText b = new RawText( + Constants.encodeASCII("a b \na b c\n\tfoo\nab\na \tb")); + + // "a\tb\t \n" == "a b \n" + assertTrue(cmp.equals(a, 0, b, 0)); + assertTrue(cmp.equals(b, 0, a, 0)); + + // "a\tb\t c \n" == "a b c\n" + assertTrue(cmp.equals(a, 1, b, 1)); + assertTrue(cmp.equals(b, 1, a, 1)); + + // " foo" == "\tfoo" + assertTrue(cmp.equals(a, 2, b, 2)); + assertTrue(cmp.equals(b, 2, a, 2)); + + // "a b" != "ab" + assertFalse(cmp.equals(a, 3, b, 3)); + assertFalse(cmp.equals(b, 3, a, 3)); + + // "a b" == "a \tb " + assertTrue(cmp.equals(a, 4, b, 4)); + assertTrue(cmp.equals(b, 4, a, 4)); + } } |