git-lfs / git-lfs

Git extension for versioning large files
https://git-lfs.com
Other
12.64k stars 2.01k forks source link

git: improve sparse checkout support #5796

Open bk2204 opened 3 weeks ago

bk2204 commented 3 weeks ago

When we invoke git ls-files to try to find all LFS files, we don't honour sparse file paths or exclusions. While we should never actually traverse excluded files, using the --exclude-standard option can avoid loading some data with filtered clones, which may result in less data being downloaded.

In addition, we can honour sparse checkouts, since this code path is only used to handle the working tree and we know that the only files we need to consider are those Git actually put in the working tree. The --sparse option is new in 2.35, but we already require 2.42 above, so we can use it unconditionally.