Skip to content

Commit

Permalink
clean/smudge: allow clean filters to process extremely large files
Browse files Browse the repository at this point in the history
The filter system allows for alterations to file contents when they're
moved between the database and the worktree. We already made sure that
it is possible for smudge filters to produce contents that are larger
than `unsigned long` can represent (which matters on systems where
`unsigned long` is narrower than `size_t`, most notably 64-bit Windows).
Now we make sure that clean filters can _consume_ contents that are
larger than that.

Note that this commit only allows clean filters' _input_ to be larger
than can be represented by `unsigned long`.

This change makes only a very minute dent into the much larger project
to teach Git to use `size_t` instead of `unsigned long` wherever
appropriate.

Helped-by: Johannes Schindelin <[email protected]>
Signed-off-by: Matt Cooper <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
vtbassmatt authored and Git for Windows Build Agent committed Jan 14, 2022
1 parent 0049b75 commit 25206c9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions t/t1051-large-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,15 @@ test_expect_success EXPENSIVE,SIZE_T_IS_64BIT,!LONG_IS_64BIT \
test $(test_file_size big) -eq $(cat big.size)
'

# This clean filter writes down the size of input it receives. By checking against
# the actual size, we ensure that cleaning doesn't mangle large files on 64-bit Windows.
test_expect_success EXPENSIVE,SIZE_T_IS_64BIT,!LONG_IS_64BIT \
'files over 4GB convert on input' '
test-tool genzeros $((5*1024*1024*1024)) >big &&
test_config filter.checklarge.clean "wc -c >big.size" &&
echo "big filter=checklarge" >.gitattributes &&
git add big &&
test $(test_file_size big) -eq $(cat big.size)
'

test_done

0 comments on commit 25206c9

Please sign in to comment.