Skip to content

Commit b79541a

Browse files
vtbassmattgitster
authored andcommitted
t1051: introduce a smudge filter test for extremely large files
The filter system allows for alterations to file contents when they're added to the database or working tree. ("Smudge" when moving to the working tree; "clean" when moving to the database.) This is used natively to handle CRLF to LF conversions. It's also employed by Git-LFS to replace large files from the working tree with small tracking files in the repo and vice versa. Git reads the entire smudged file into memory to convert it into a "clean" form to be used in-core. While this is inefficient, there's a more insidious problem on some platforms due to inconsistency between using unsigned long and size_t for the same type of data (size of a file in bytes). On most 64-bit platforms, unsigned long is 64 bits, and size_t is typedef'd to unsigned long. On Windows, however, unsigned long is only 32 bits (and therefore on 64-bit Windows, size_t is typedef'd to unsigned long long in order to be 64 bits). Practically speaking, this means 64-bit Windows users of Git-LFS can't handle files larger than 2^32 bytes. Other 64-bit platforms don't suffer this limitation. This commit introduces a test exposing the issue; future commits make it pass. The test simulates the way Git-LFS works by having a tiny file checked into the repository and expanding it to a huge file on checkout. Helped-by: Johannes Schindelin <[email protected]> Signed-off-by: Matt Cooper <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 970fa57 commit b79541a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

t/t1051-large-conversion.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,19 @@ test_expect_success 'ident converts on output' '
8383
test_cmp small.clean large.clean
8484
'
8585

86+
# This smudge filter prepends 5GB of zeros to the file it checks out. This
87+
# ensures that smudging doesn't mangle large files on 64-bit Windows.
88+
test_expect_failure EXPENSIVE,SIZE_T_IS_64BIT,!LONG_IS_64BIT \
89+
'files over 4GB convert on output' '
90+
test_commit test small "a small file" &&
91+
small_size=$(test_file_size small) &&
92+
test_config filter.makelarge.smudge \
93+
"test-tool genzeros $((5*1024*1024*1024)) && cat" &&
94+
echo "small filter=makelarge" >.gitattributes &&
95+
rm small &&
96+
git checkout -- small &&
97+
size=$(test_file_size small) &&
98+
test "$size" -eq $((5 * 1024 * 1024 * 1024 + $small_size))
99+
'
100+
86101
test_done

0 commit comments

Comments
 (0)