KEMBAR78
git lfs clone for submodules · Issue #1172 · git-lfs/git-lfs · GitHub
Skip to content

git lfs clone for submodules #1172

@larsxschneider

Description

@larsxschneider

I realized that the git lfs clone speed up does not work with Git Submodules and I wonder if anyone has a clever idea to approach this problem. Here is my first wrapper script attempt:

git-lfs clone $@
if [[ -z $2 ]]; then
    CLONE_PATH=$(basename ${1%.git});
else
    CLONE_PATH=$2;
fi
pushd "$CLONE_PATH"
    git submodule init
    wt_prefix=$(git rev-parse --show-prefix)
    git submodule--helper list --prefix "$wt_prefix" | {
        while read mode sha1 stage sm_path
        do
            name=$(git submodule--helper name "$sm_path") || exit
            url=$(git config submodule."$name".url)
            if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
            then
                git submodule--helper clone --prefix "$wt_prefix" --path "$sm_path" --name "$name" --url "$url"
                pushd "$sm_path"
                    git -c filter.lfs.smudge=cat checkout -q $sha1 || exit
                    git-lfs pull || exit
                popd
            fi
        done
    }
popd

This works by taking the relevant pieces from the git submodule command. However, this is probably a pretty fragile solution. I would prefer to use higher level Submodule commands. @sinbad @stefanbeller any better idea or do you think this is the way to go?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions