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

Re: [PATCH] clone: teach --single-branch and --branch during --recurse

From
Jeff King <peff@peff.net>
Date
Jan 17, 2020, 21:03 UTC
Message-ID
<20200117210319.GA15460@coredump.intra.peff.net>
In-Reply-To
<20200116223800.GM181522@google.com>
On Thu, Jan 16, 2020 at 02:38:00PM -0800, Emily Shaffer wrote:
Show 12 quoted lines
> > I have no idea how common this kind of thing would be, and I expect in
> > most cases your patch would do what people want. But we might need to be
> > better about retrying without those options when the first clone fails.
> 
> Yeah, that's interesting. A retry sounds like a pretty solid approach,
> although if someone's being cautious and using --single-branch I wonder
> if that's really something they want (since that's avoiding grabbing
> extraneous branches).
> 
> I suppose at the very least, --single-branch without --branch should
> become recursive. Whether --branch should become recursive, I'm not
> totally sure.

Yeah, I think it may be worth separating out how to think about the two options. It's a lot more plausible to me that --single-branch would want to recurse than --branch.

Show 31 quoted lines
> The two scenarios I see in conflict are this:
> - Superproject branch "foo"
>   - submodule A branch "foo"
>   - submodule B branch "foo"
> and
> - Superproject branch "foo"
>   - submodule A branch "bar"
>   - submodule B branch "baz"
> 
> If we propagate --branch, the first scenario Just Works, and the second
> scenario requires something like:
> 
>  git clone --recurse-submodules=no --single-branch --branch foo https://superproject
>  git submodule update --init --single-branch --branch bar A/
>  git submodule update --init --single-branch --branch baz B/
> 
> (I guess if the superproject knows what branch it wants for all the submodules,
> you could also just do "git submodule update --init --single-branch" and
> have it go and ask for all of them.)
> 
> If we don't propagate --branch, the second scenario Just Works, and the
> first scenario requires something like:
> 
>  git clone --recurse-submodules=no --single-branch --branch foo https://superproject
>  git submodule update --init --single-branch --branch foo
> 
> (That is, I think as long as 'update' takes --branch, even if it's not
> passed along by 'clone', it should still work OK when delegating to
> everyone.)
> 
> Let me know if I misunderstood what you were worried about.

Right, that's exactly my concern. You're making one case work but breaking the other.

It really seems like there's no particular reason to assume that the superproject branch corresponds to the submodule branch (or even submodules of submodules). I imagine it would in some cases (like trying to replace the use of "repo" in Android), but that's just one model.

It would make more sense to me to either (or both):
  - make sure that .gitmodules has enough information about which branch
    to use for each submodule
  - offer an extra option for the default branch to use for any
    submodules. This is still not general enough to cover all situations
    (e.g., the bar/baz you showed above), but it at least makes it
    relatively easy to cover the simple cases, without breaking any
    existing ones.
-Peff
Previous: Emily ShafferNext: Emily Shaffer
Message 5 of 22 in “clone: teach --single-branch and --branch during --recurse”
  1. clone: teach --single-branch and --branch during --recurseEmily Shaffer, Jan 8, 2020
  2. Emily ShafferJan 8, 2020
  3. Jeff KingJan 9, 2020
  4. Emily ShafferJan 16, 2020
  5. Jeff KingJan 17, 2020
  6. Emily ShafferJan 27, 2020
  7. Emily ShafferJan 27, 2020
  8. Jeff KingJan 27, 2020
  9. Emily ShafferJan 28, 2020
  10. Jeff KingJan 28, 2020
  11. Emily ShafferJan 28, 2020
  12. Jeff KingJan 27, 2020
  13. clone: pass --single-branch during --recurse-submodulesEmily Shaffer, Jan 28, 2020
  14. Jeff KingJan 30, 2020
  15. Emily ShafferFeb 21, 2020
  16. Jeff KingFeb 21, 2020
  17. 0/2 propagate --single-branch during clone --recurse-submodulesEmily Shaffer, Feb 21, 2020
  18. 1/2 submodule--helper: use C99 named initializerEmily Shaffer, Feb 21, 2020
  19. Jeff KingFeb 21, 2020
  20. Junio C HamanoFeb 22, 2020
  21. 2/2 clone: pass --single-branch during --recurse-submodulesEmily Shaffer, Feb 21, 2020
  22. Jeff KingFeb 21, 2020

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.