Ignore core.eol if core.autocrlf=input

Config core.eol is to be ignored if core.autocrlf is true or input.[1]
JGit didn't do so when core.autocrlf=input was set.

[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreeol

Bug: 561877
Change-Id: I5e62e0510d160b5113c1090319af09c2bc1bcb59
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java
index 7b90dcd..5d05a98 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java
@@ -26,7 +26,9 @@
 import org.eclipse.jgit.dircache.DirCache;
 import org.eclipse.jgit.dircache.DirCacheEntry;
 import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.eclipse.jgit.lib.ConfigConstants;
 import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
 import org.eclipse.jgit.util.IO;
 import org.eclipse.jgit.util.RawParseUtils;
 import org.junit.Test;
@@ -39,6 +41,36 @@
 public class AttributeFileTests extends RepositoryTestCase {
 
 	@Test
+	public void testTextAutoCoreEolCoreAutoCrLfInput() throws Exception {
+		FileBasedConfig cfg = db.getConfig();
+		cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+				ConfigConstants.CONFIG_KEY_AUTOCRLF, false);
+		cfg.save();
+		final String content = "Line1\nLine2\n";
+		try (Git git = Git.wrap(db)) {
+			writeTrashFile(".gitattributes", "* text=auto");
+			File dummy = writeTrashFile("dummy.txt", content);
+			git.add().addFilepattern(".").call();
+			git.commit().setMessage("Commit with LF").call();
+			assertEquals("Unexpected index state",
+					"[.gitattributes, mode:100644, content:* text=auto]"
+							+ "[dummy.txt, mode:100644, content:" + content
+							+ ']',
+					indexState(CONTENT));
+			assertTrue("Should be able to delete " + dummy, dummy.delete());
+			cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
+					ConfigConstants.CONFIG_KEY_EOL, "crlf");
+			cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
+					ConfigConstants.CONFIG_KEY_AUTOCRLF, "input");
+			cfg.save();
+			git.reset().setMode(ResetType.HARD).call();
+			assertTrue("File " + dummy + "should exist", dummy.isFile());
+			String textFile = RawParseUtils.decode(IO.readFully(dummy, 512));
+			assertEquals("Unexpected text content", content, textFile);
+		}
+	}
+
+	@Test
 	public void testTextAutoEolLf() throws Exception {
 		writeTrashFile(".gitattributes", "* text=auto eol=lf");
 		performTest("Test\r\nFile", "Test\nFile", "Test\nFile");
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java
index a6acb40..c33c869 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java
@@ -168,6 +168,8 @@
 		switch (options.getAutoCRLF()) {
 		case TRUE:
 			return EolStreamType.TEXT_CRLF;
+		case INPUT:
+			return EolStreamType.DIRECT;
 		default:
 			// no decision
 		}