git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [RFC] How to pass Git config command line instructions to Submodule commands?
@ 2016-04-25 10:39 Lars Schneider
  2016-04-25 17:02 ` Stefan Beller
  0 siblings, 1 reply; 36+ messages in thread
From: Lars Schneider @ 2016-04-25 10:39 UTC (permalink / raw)
  To: Git Users; +Cc: Stefan Beller

Hi,

a few folks from the Git LFS project and I try to make cloning of repositories 
with a lot of LFS files faster. 

The core problem is that Git LFS uses a Git smudge filter to replace LFS 
pointers with the actual file content. Right now, a smudge filter can only 
be executed on an individual file which makes the operation slow for many 
files [1].

We solved this issue by temporarily disabling the smudge filter for the clone 
command via Git config (optimized in 1a8630 [2]):

    git -c filter.lfs.smudge= -c filter.lfs.required=false clone <url> <path>

Afterwards Git LFS runs a special command to download and replace all LFS 
content in bulk [3]. This works great for LFS repositories.

However, I noticed that git config command line instructions such as 
"-c filter.lfs.smudge=" are not passed to Git submodule operations. Thus
this does not work as expected:

    git -c filter.lfs.smudge= -c filter.lfs.required=false clone --recursive <url> <path>

I tried to work around that by copying the relevant pieced from the Git 
Submodule command [4] and applying the command line Git config
manually (look closely at the modified checkout command):

    git -c filter.lfs.smudge= -c filter.lfs.required=false 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= -c filter.lfs.required=false checkout -q $sha1 || exit
                        git-lfs pull || exit
                    popd
                fi
            done
        }
    popd

Do you see an easier way to pass command line Git config instructions to the 
underlaying Git Submodule commands? If not, do you think a patch adding this
would be worth working on?

I also started a discussion about that on the Git LFS issue page [5].

Thanks,
Lars


[1] https://github.com/github/git-lfs/issues/931
[2] https://github.com/git/git/commit/1a8630dc3b1cc6f1361a4e5d94630133c24c97d9
[3] https://developer.atlassian.com/blog/2016/04/git-lfs-12-clone-faster/
[4] https://github.com/git/git/blob/6a6636270fbaf74609cd3e1bd207dd2c420d640a/git-submodule.sh#L686-L731
[5] https://github.com/github/git-lfs/issues/1172

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2016-04-28 16:54 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25 10:39 [RFC] How to pass Git config command line instructions to Submodule commands? Lars Schneider
2016-04-25 17:02 ` Stefan Beller
2016-04-25 20:59   ` Jacob Keller
2016-04-25 21:24     ` Jeff King
2016-04-25 21:27       ` Jeff King
2016-04-28 11:06       ` Lars Schneider
2016-04-28 11:25         ` Jeff King
2016-04-28 12:05           ` Jeff King
2016-04-28 12:17             ` Jeff King
2016-04-28 13:35               ` [PATCH 0/5] fixes for sanitized submodule config Jeff King
2016-04-28 13:36                 ` [PATCH 1/5] t5550: fix typo in $HTTPD_URL Jeff King
2016-04-28 15:24                   ` Jacob Keller
2016-04-28 15:25                     ` Jeff King
2016-04-28 15:26                       ` Jacob Keller
2016-04-28 13:37                 ` [PATCH 2/5] t5550: break submodule config test into multiple sub-tests Jeff King
2016-04-28 15:21                   ` Stefan Beller
2016-04-28 15:25                     ` Jeff King
2016-04-28 15:25                     ` Jacob Keller
2016-04-28 13:37                 ` [PATCH 3/5] submodule: export sanitized GIT_CONFIG_PARAMETERS Jeff King
2016-04-28 15:25                   ` Stefan Beller
2016-04-28 15:28                     ` Jeff King
2016-04-28 15:35                       ` Stefan Beller
2016-04-28 16:51                       ` Johannes Schindelin
2016-04-28 15:28                   ` Jacob Keller
2016-04-28 15:36                     ` Jeff King
2016-04-28 15:40                       ` Jacob Keller
2016-04-28 13:38                 ` [PATCH 4/5] submodule--helper: move config-sanitizing to submodule.c Jeff King
2016-04-28 15:30                   ` Stefan Beller
2016-04-28 15:37                     ` Jeff King
2016-04-28 16:28                   ` Lars Schneider
2016-04-28 13:39                 ` [PATCH 5/5] submodule: use prepare_submodule_repo_env consistently Jeff King
2016-04-28 14:02                 ` [PATCH 0/5] fixes for sanitized submodule config Johannes Schindelin
2016-04-28 15:56                   ` Stefan Beller
2016-04-28 16:03                     ` Jacob Keller
2016-04-28 12:05           ` [RFC] How to pass Git config command line instructions to Submodule commands? Lars Schneider
2016-04-28 13:40             ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).