diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-12-26 01:22:04 +0100 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2014-02-02 13:16:19 +0100 |
commit | 5404e70dc64201786cd6a21efb41310912860122 (patch) | |
tree | bb3ac6ab7850c50f8a59e755578ca14b3a88e158 /org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java | |
parent | 8352d1729ca63d4d6d831b2da0b168c950bc6f52 (diff) | |
download | jgit-5404e70dc64201786cd6a21efb41310912860122.tar.gz jgit-5404e70dc64201786cd6a21efb41310912860122.zip |
Fix for core.autocrlf=input resulting in modified file
This version does not attempt to unsmudge, unlike the first attempt
in Idafad150553df14827eccfde2e3b95760e16a8b6.
Bug: 372834
Change-Id: I9300e735cb16d6208e1df963abb1ff69f688155d
Also-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java index 64e72e8fc7..a1e16e4cf7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java @@ -68,9 +68,11 @@ import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.junit.RepositoryTestCase; +import org.eclipse.jgit.lib.CoreConfig.AutoCRLF; import org.eclipse.jgit.lib.IndexDiff.StageState; import org.eclipse.jgit.merge.MergeStrategy; import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.treewalk.FileTreeIterator; import org.eclipse.jgit.util.IO; import org.junit.Test; @@ -576,6 +578,35 @@ public class IndexDiffTest extends RepositoryTestCase { assertTrue(StageState.BOTH_ADDED.hasTheirs()); } + @Test + public void testAutoCRLFInput() throws Exception { + Git git = new Git(db); + FileBasedConfig config = db.getConfig(); + + // Make sure core.autocrlf is false before adding + config.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_AUTOCRLF, AutoCRLF.FALSE); + config.save(); + + // File is already in repository with CRLF + writeTrashFile("crlf.txt", "this\r\ncontains\r\ncrlf\r\n"); + git.add().addFilepattern("crlf.txt").call(); + git.commit().setMessage("Add crlf.txt").call(); + + // Now set core.autocrlf to input + config.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null, + ConfigConstants.CONFIG_KEY_AUTOCRLF, AutoCRLF.INPUT); + config.save(); + + FileTreeIterator iterator = new FileTreeIterator(db); + IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator); + diff.diff(); + + assertTrue( + "Expected no modified files, but there were: " + + diff.getModified(), diff.getModified().isEmpty()); + } + private void verifyStageState(StageState expected, int... stages) throws IOException { DirCacheBuilder builder = db.lockDirCache().builder(); |