]> source.dussan.org Git - jgit.git/commitdiff
Revert "Quickfix for AutoCRLF handling" 66/5366/1
authorShawn O. Pearce <spearce@spearce.org>
Thu, 15 Mar 2012 14:21:14 +0000 (07:21 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Thu, 15 Mar 2012 14:22:24 +0000 (07:22 -0700)
This reverts commit 88fe2836edab8d8ce82d28acd9d07b061988ff3a.

Auto CRLF isn't special enough to be screwing around with the buffers
used for raw byte processing of the ObjectInserter API. If it needs a
buffer to process a file that is bigger than the buffer allocated by
an ObjectInserter, it needs to do its own buffer management.

Change-Id: Ida4aaa80d0f9f78035f3d2a9ebdde904c980f89a

org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/ObjectDirectoryInserter.java

index 07173a9c33a922b8bda011f2762705e7c8098822..d989b63b24162a85d801df16827eab6d0641af17 100644 (file)
@@ -114,7 +114,7 @@ public class AddCommandTest extends RepositoryTestCase {
        }
 
        @Test
-       public void testAddExistingSingleSmallFileWithNewLine() throws IOException,
+       public void testAddExistingSingleFileWithNewLine() throws IOException,
                        NoFilepatternException {
                File file = new File(db.getWorkTree(), "a.txt");
                FileUtils.createNewFile(file);
@@ -137,35 +137,6 @@ public class AddCommandTest extends RepositoryTestCase {
                                indexState(CONTENT));
        }
 
-       @Test
-       public void testAddExistingSingleMediumSizeFileWithNewLine()
-                       throws IOException, NoFilepatternException {
-               File file = new File(db.getWorkTree(), "a.txt");
-               FileUtils.createNewFile(file);
-               StringBuilder data = new StringBuilder();
-               for (int i = 0; i < 1000; ++i) {
-                       data.append("row1\r\nrow2");
-               }
-               String crData = data.toString();
-               PrintWriter writer = new PrintWriter(file);
-               writer.print(crData);
-               writer.close();
-               String lfData = data.toString().replaceAll("\r", "");
-               Git git = new Git(db);
-               db.getConfig().setString("core", null, "autocrlf", "false");
-               git.add().addFilepattern("a.txt").call();
-               assertEquals("[a.txt, mode:100644, content:" + data + "]",
-                               indexState(CONTENT));
-               db.getConfig().setString("core", null, "autocrlf", "true");
-               git.add().addFilepattern("a.txt").call();
-               assertEquals("[a.txt, mode:100644, content:" + lfData + "]",
-                               indexState(CONTENT));
-               db.getConfig().setString("core", null, "autocrlf", "input");
-               git.add().addFilepattern("a.txt").call();
-               assertEquals("[a.txt, mode:100644, content:" + lfData + "]",
-                               indexState(CONTENT));
-       }
-
        @Test
        public void testAddExistingSingleBinaryFile() throws IOException,
                        NoFilepatternException {
index e03fe3571931accc202f7041c7eacde7fe5453dd..0355e56f5fc6bfeb8b5bbece1e9feca348cc967f 100644 (file)
@@ -109,29 +109,6 @@ public abstract class ObjectInserter {
                return tempBuffer;
        }
 
-       static private final int tempBufSize;
-       static {
-               String s = System.getProperty("jgit.tempbufmaxsize");
-               if (s != null)
-                       tempBufSize = Integer.parseInt(s);
-               else
-                       tempBufSize = 1000000;
-       }
-
-       /**
-        * @param hintSize
-        * @return a temporary byte array for use by the caller
-        */
-       protected byte[] buffer(long hintSize) {
-               if (hintSize >= tempBufSize)
-                       tempBuffer = new byte[0];
-               else if (tempBuffer == null)
-                       tempBuffer = new byte[(int) hintSize];
-               else if (tempBuffer.length < hintSize)
-                       tempBuffer = new byte[(int) hintSize];
-               return tempBuffer;
-       }
-
        /** @return digest to help compute an ObjectId */
        protected MessageDigest digest() {
                digest.reset();
@@ -195,7 +172,7 @@ public abstract class ObjectInserter {
                md.update((byte) ' ');
                md.update(Constants.encodeASCII(length));
                md.update((byte) 0);
-               byte[] buf = buffer(length);
+               byte[] buf = buffer();
                while (length > 0) {
                        int n = in.read(buf, 0, (int) Math.min(length, buf.length));
                        if (n < 0)
index e80a324752d5ad73771d725faf51b022ab958e6b..335e284e2b74beae039c9d8fcbc81a1712742495 100644 (file)
@@ -116,7 +116,7 @@ public class DfsInserter extends ObjectInserter {
        @Override
        public ObjectId insert(int type, long len, InputStream in)
                        throws IOException {
-               byte[] buf = buffer(len);
+               byte[] buf = buffer();
                if (len <= buf.length) {
                        IO.readFully(in, buf, 0, (int) len);
                        return insert(type, buf, 0, (int) len);
index 75f6b0bdaac30e4b1e76a037731cb1b14a9418e1..ffd5c4149f6a1b10ef384fbfcb0792c46a881cc8 100644 (file)
@@ -95,8 +95,8 @@ class ObjectDirectoryInserter extends ObjectInserter {
        @Override
        public ObjectId insert(final int type, long len, final InputStream is)
                        throws IOException {
-               byte[] buf = buffer(len);
-               if (len <= buf.length) {
+               if (len <= buffer().length) {
+                       byte[] buf = buffer();
                        int actLen = IO.readFully(is, buf, 0);
                        return insert(type, buf, 0, actLen);