Optimize pre-commit download
Optimize the amount of data the pre-commit hook downloads, significantly reducing it from ~600MiB to ~500KiB. This is done by using a Git feature named Partial Clone, which is supported since 2.18 (released 2018). With older Git versions it falls back to the previous behaviour of doing a full clone.
Fixes #3322
@danner26 @DanSheps Thoughts on this?
@m-hau I will have to dig into this further, but I believe this is just cloning the head commit (i.e. the latest in the branch), is that correct?
Using git clone https://... to do a "normal" clone, it will a) download the whole history (all revisions of all past and present files) into the .git directory and b) populate the working directory with the files/state of the last commit. This will download 654MiB of data, and consume 1,31GiB of disk-space (or RAM in the case of tmpfs). That is what the hook is currently doing.
Using git clone --depth=1 https://... you are doing a "shallow clone", which reduces a) from the whole history to just the last commit. This will download 561MiB of data, and consume 1,22GiB of disk-space (or RAM in the case of tmpfs). Most of this data are the elevation-images, which are not required for the hook.
Using git clone --depth=1 --no-checkout https://... you are skipping b) entirely, and can then selectively checkout the files you actually need in your working copy. This will download 561MiB of data, and consume 562MiB of disk-space (or RAM in the case of tmpfs). That is what the new hook is doing as fallback.
Using git clone --depth=1 --no-checkout --filter=blob:none https://... you are doing a "partial clone", reducing a) to just the metadata of the last commit (skipping any file contents) and skipping b) entirely. You can then selectively checkout the files you actually need in your working copy, which will automatically trigger a download of the required file contents. This will download 372KiB of data, and consume 868KiB of disk-space (or RAM in the case of tmpfs). That is what the new hook is doing.
So yeah, reducing the download amount and disk/ram-usage required a bit more than "just cloning the head commit", because the elevation-images make even just the last commit huge.