git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug? git submodule update --reference doesn't use the referenced repository

From
Stefan Beller <sbeller@google.com>
Date
Apr 3, 2017, 16:32 UTC
Message-ID
<CAGZ79kYKfKcVcV9ddRHNc-aQ7RpN4ToDs9i=voqXcKTm79j3KA@mail.gmail.com>
In-Reply-To
<35343b75-0aa7-3477-888b-3af5024ae7dd@serato.com>

On Sun, Apr 2, 2017 at 8:13 PM, Maxime Viargues <maxime.viargues@serato.com> wrote:

Show 6 quoted lines
> Hi there,
>
> I have been trying to use the --reference option to clone a big repository
> using a local copy, but I can't manage to make it work using sub-module
> update. I believe this is a bug, unless I missed something.
> I am on Windows, Git 2.12.0
which is new enough, that the new --reference code is in. :)
Show 17 quoted lines
>
> So the problem is as follow:
> - I have got a repository with multiple sub-modules, say
>     main
>         lib1
>             sub-module1.git
>         lib2
>             sub-module2.git
> - The original repositories are in GitHub, which makes it slow
> - I have done a normal git clone of the entire repository (not bare) and put
> it on a file server, say \\fileserver\ref_repo\
> (Note that the problem also happens with local copy)
>
> So if I do a clone to get the repo and all the submodules with...
> git clone --reference-if-able \\fileserver\ref-repo --recursive
> git@github.com:company/main
> ...then it all works, all the sub-modules get cloned and the it's fast.
great. :)
Show 8 quoted lines
> Now in my case I am working with Jenkins jobs and I need to first do a
> clone, and then get the sub-modules, but if I do...
> git clone --reference-if-able \\fileserver\ref-repo
> git@github.com:company/main (so non-recursive)
> cd main
> git submodule update --init --reference \\fileserver\ref-repo
> ... then this takes ages, as it would normally do without the use of
> --reference. I suspect it's not actually using it.
So to confirm your suspicion, can you run
  GIT_TRACE=1 git clone ...
  cd main && GIT_TRACE=1 git submodule update ...

to see which child processes are spawned to deal with the submodules? Also to confirm, it is the "submodule update" that is taking so long for you?

> The git clone documentation mentions that the reference is then passed to
> the sub-module clone commands, so I would expect "git clone --recursive" to
> work the same as "git submodule update", as far as --reference is concerned.
Oh, there we have an opportunity to improve the man page (or the code).
    git clone --reference --recursive ...
will set the config variables
    git config submodule.alternateLocation superproject
    git config submodule.alternateErrorStrategy die (or "info" for
--reference-if-able)

and the clone for the submodules (that are an independent process, just run after the clone of the superproject is done) will pickup these config variables and act accordingly.

If you only run
    git clone --reference ...

then these variables are not set. Probably they should be set such that the later invocation of "git submodule update --int" will behave the same as the git-clone of the superproject did.

So as a workaround for you to get up to speed again, you can just set these config variables yourself before running the "submodule update --init" and it should work.

Show 7 quoted lines
>
> I noticed for a single module, doing a...
> git submodule update --init --reference
> \\fileserver\ref-repo\lib1\sub-module1 -- lib1/sub-module1
> ...i.e. adding the sub-module path to the reference path, works. Which kind
> of make sense but then how do you do to apply it to all the sub-modules?
> (without writing a script to do that)

I think that functionality is broken as it takes the same reference for all submodules, such that you need to go through the submodules one by one and give the submodule specific reference location.

Show 5 quoted lines
>
> If someone can confirm the problem or explain me what I am dong wrong that
> would be great.
>
> Maxime
Stefan
Previous: Maxime ViarguesNext: Maxime Viargues
Message 2 of 3 in “Bug? git submodule update --reference doesn't use the referenced repository”
  1. Maxime ViarguesApr 3, 2017
  2. Stefan BellerApr 3, 2017
  3. Maxime ViarguesApr 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.