]> source.dussan.org Git - jgit.git/commit
Make the buffer size for text/binary detection configurable 89/187189/2
authorThomas Wolf <thomas.wolf@paranor.ch>
Tue, 12 Oct 2021 22:28:38 +0000 (00:28 +0200)
committerThomas Wolf <thomas.wolf@paranor.ch>
Sat, 30 Oct 2021 21:05:22 +0000 (23:05 +0200)
commitc2204bb6835e4e6dc666bb34eaea910fb1484092
treeed31d5d1009a7968fc3e75d72de71fee392f8715
parent331a489c7f116f98da6e6b6614af73a0a255b8e8
Make the buffer size for text/binary detection configurable

The various streams used in JGit for text/binary and CR-LF detection
used different buffer sizes. Most used 8000, but one used 8KiB, and one
used 8096 (SIC!) bytes.

Considering only the first 8kB of a file/blob is not sufficient; it
may give behavior incompatible with C git. C git considers the whole
blob; since it uses memory-mapped files it can do so with acceptable
performance. Doing this in JGit would most likely incur a noticeable
performance penalty. But 8kB is a bit small; in the file in bug 576971
the limit was hit before the first CR-LF, which occurred on line 155
at offset 9759 in the file.

Make RawText.FIRST_FEW_BYTES only a default and minimum setting, and
set it to 8KiB. Make the actual buffer size configurable: provide
static methods getBufferSize() and setBuffersize(), and use
getBufferSize() throughout instead of the constant.

This enables users of the JGit library to set their own possibly larger
buffer size.

Bug: 576971
Change-Id: I447762c9a5147a521f73d2864ba59ed89f555d54
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/DiffFormatterTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java
org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFOutputStream.java
org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoLFInputStream.java
org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoLFOutputStream.java