Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Using git lfs pull --include ... in a Shallow clones and sparse checkout causes git to download all blobs one by one. #5689

Description

@mattrq

Describe the bug
LFS's use of the git ls-tree with -l when using the --include option in a filtered clone causes git to fetch the missing blobs one by one.
Omitting the -l, does not happen.

To Reproduce

git clone --filter=tree:0 --depth=1 --no-checkout --no-tags [email protected]:git-lfs/git-lfs.git
cd git-lfs
git sparse-checkout set commands --cone
git checkout main
# Git ls-tree without -l
time git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'ls-tree' '-r' '-z' '--full-tree' HEAD
# Git ls-tree with -l
time git '-c' 'filter.lfs.smudge=' '-c' 'filter.lfs.clean=' '-c' 'filter.lfs.process=' '-c' 'filter.lfs.required=false' 'ls-tree' '-l' '-r' '-z' '--full-tree' HEAD
GIT_TRACE git lfs pull -I command 2>&1 | grep ls-tree

Observations:
The ls-tree run with -l, is far slower.
The git lfs pull calls ls-tree with -l.

Expected behavior
Allow git ls-tree to make a first pass without the -l option when it is only used to filter path names.

System environment
Mac OS

Output of git lfs env
git lfs env
git-lfs/3.4.1 (GitHub; darwin arm64; go 1.21.5)
git version 2.44.0

Endpoint=https://github.com/git-lfs/git-lfs.git/info/lfs (auth=none)
SSH=[email protected]:git-lfs/git-lfs.git
LocalWorkingDir=/Users/mrosenquist/git-lfs
LocalGitDir=/Users/mrosenquist/git-lfs/.git
LocalGitStorageDir=/Users/mrosenquist/git-lfs/.git
LocalMediaDir=/Users/mrosenquist/git-lfs/.git/lfs/objects
LocalReferenceDirs=
TempDir=/Users/mrosenquist/git-lfs/.git/lfs/tmp
ConcurrentTransfers=8
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=/Users/mrosenquist/git-lfs/.git/lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic,lfs-standalone-file,ssh
UploadTransfers=basic,lfs-standalone-file,ssh
GIT_EXEC_PATH=/opt/homebrew/opt/git/libexec/git-core
GIT_TRACE2_PARENT_NAME=run_dashed
GIT_TRACE2_PARENT_SID=20240327T232438.979651Z-Hbf43c273-P00017815
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"

Additional context
The use of -l on ls-tree prevents the manual filtering to match sparse-checkout rules while git-lfs does not directly support sparse checkouts.

Related issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions