]> source.dussan.org Git - jgit.git/commit
Skip detecting content renames for large files 53/177553/5
authorYoussef Elghareeb <ghareeb@google.com>
Thu, 11 Mar 2021 12:01:14 +0000 (13:01 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 14 Mar 2021 10:38:13 +0000 (11:38 +0100)
commit4a78d911c578a6f9028d6e74b5668dfc384ef80f
tree6dc5c597adab84b5043bad901fc9aa1456bbb314
parent84ed57d2f63307437492f3a2c9b60ce7737b96e6
Skip detecting content renames for large files

There are two code paths for detecting renames: one on tree diffs
(using DiffFormatter#scan) and the other on single file diffs (using
DiffFormatter#format). The latter skips binary and large files
for rename detection - check [1], but the former doesn't.

This change skips content rename detection for the tree diffs case for
large files. This is essential to avoid expensive computations while
reading the file, especially for callers who don't want to pay that
cost. Content renames are those which involve files with slightly
modified content. Exact renames will still be identified.

The default threshold for file sizes is reused from
PackConfig.DEFAULT_BIG_FILE_THRESHOLD: 50 MB.

[1] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/232876421d067a1242e8afcaa33b9171342fee3e/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java#386

Change-Id: Idbc2c29bd381c6e387185204638f76fda47df41e
Signed-off-by: Youssef Elghareeb <ghareeb@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java