diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2011-10-31 23:30:11 +0100 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-01-10 23:15:52 +0100 |
commit | 76dd9d1d46007fc49639d264631658114f4fbd24 (patch) | |
tree | 63800bce5975e8d93db22c3bf4bdcce845c4c21d /org.eclipse.jgit.test/tst/org/eclipse/jgit/lib | |
parent | 6a582970bfa1120dfe99e7568ea2d471dfc59387 (diff) | |
download | jgit-76dd9d1d46007fc49639d264631658114f4fbd24.tar.gz jgit-76dd9d1d46007fc49639d264631658114f4fbd24.zip |
Support more of AutoCRLF
This patch introduces CRLF handling to the DirCacheCheckout and
WorkingTreeIterator supporting the AutoCRLF for add, checkout
reset and status and hopefully some other places that depende
on the underlying logic of the affected API's.
The patch includes test cases for the Status command provided by
Tomasz Zarna for bug 353867.
The core.eol and core.safecrlf options are not yet supported.
Bug: 301775
Bug: 353867
Change-Id: I2280a2dc0698829475de6a662a6c6e80b1df7663
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/lib')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java index f06b37c842..fafd745b5a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java @@ -40,6 +40,7 @@ */ package org.eclipse.jgit.lib; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -879,6 +880,41 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { } @Test + public void testCheckoutOutChangesAutoCRLFfalse() throws IOException { + setupCase(mk("foo"), mkmap("foo/bar", "foo\nbar"), mk("foo")); + checkout(); + assertIndex(mkmap("foo/bar", "foo\nbar")); + assertWorkDir(mkmap("foo/bar", "foo\nbar")); + } + + @Test + public void testCheckoutOutChangesAutoCRLFInput() throws IOException { + setupCase(mk("foo"), mkmap("foo/bar", "foo\nbar"), mk("foo")); + db.getConfig().setString("core", null, "autocrlf", "input"); + checkout(); + assertIndex(mkmap("foo/bar", "foo\nbar")); + assertWorkDir(mkmap("foo/bar", "foo\nbar")); + } + + @Test + public void testCheckoutOutChangesAutoCRLFtrue() throws IOException { + setupCase(mk("foo"), mkmap("foo/bar", "foo\nbar"), mk("foo")); + db.getConfig().setString("core", null, "autocrlf", "true"); + checkout(); + assertIndex(mkmap("foo/bar", "foo\nbar")); + assertWorkDir(mkmap("foo/bar", "foo\r\nbar")); + } + + @Test + public void testCheckoutOutChangesAutoCRLFtrueBinary() throws IOException { + setupCase(mk("foo"), mkmap("foo/bar", "foo\nb\u0000ar"), mk("foo")); + db.getConfig().setString("core", null, "autocrlf", "true"); + checkout(); + assertIndex(mkmap("foo/bar", "foo\nb\u0000ar")); + assertWorkDir(mkmap("foo/bar", "foo\nb\u0000ar")); + } + + @Test public void testCheckoutUncachedChanges() throws IOException { setupCase(mk("foo"), mk("foo"), mk("foo")); writeTrashFile("foo", "otherData"); @@ -931,9 +967,8 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { offset += numRead; } is.close(); - assertTrue("unexpected content for path " + path - + " in workDir. Expected: <" + expectedValue + ">", - Arrays.equals(buffer, i.get(path).getBytes())); + assertArrayEquals("unexpected content for path " + path + + " in workDir. ", buffer, i.get(path).getBytes()); nrFiles++; } } |