git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [Bug] 'git submodule update --single-branch' still fetching master
@ 2021-01-06  0:19 - -
  2021-01-06 19:30 ` Philippe Blain
  0 siblings, 1 reply; 3+ messages in thread
From: - - @ 2021-01-06  0:19 UTC (permalink / raw)
  To: git@vger.kernel.org

Hello,

I encountered today some problems while trying to track a single branch with 'git submodule add' and 'git submodule update'. Please find my bug report below.
Any help would be very welcome! :)

Kind regards,
Sven Krummen


What did you do before the bug happened? (Steps to reproduce your issue)
I've got two repositories, 'project' and 'lib', and I want to add 'lib' into 'project' as a git submodule.
The 'lib' repository contains the 'master' branch, which is quite heavy-weighted (~900MB), and a 'light' branch (~10MB) with a mostly unrelated history to 'master'. The 'master' branch is the default branch.
Similar to using 'git clone -b light --single-branch path/to/lib' I want to track only the 'light' branch as a submodule to reduce traffic on our build server.

To add the submodule to 'project' I tried to run:
(a) 'git submodule add -b light path/to/lib'
(b) 'git submodule add -b light --single-branch path/to/lib'
But git was always fetching the whole 'master' branch of 'lib' before switching to 'light'.

After commiting & pushing everything to 'project''s remote, I started over with a fresh clone of 'project' to test whether 'git submodule update' would only fetch the 'light' branch (typical use-case for our build jobs):
(c) 'git clone path/to/project && cd project'
(d) 'git submodule update --init --remote --single-branch lib'
But again, git was fetching the whole 'master' branch of 'lib' before switching to 'light'. This behaviour seems to be independent of the used options of 'git submodule update'.


What did you expect to happen? (Expected behavior)
(a) or (b) To create a submodule which is tracking the 'light' branch of 'lib' and to fetch *only* this branch.
(d) To fetch and checkout *only* the 'light' branch of 'lib'.


What happened instead? (Actual behavior)
(a) Fetching 'master' (or the full 'lib' repo?), then checking out the 'light' branch.
(b) Error as option '--single-branch' is not supported for 'git submodule add'.
(d) Fetching 'master' (or the full 'lib' repo?), then checking out the 'light' branch.


What's different between what you expected and what actually happened?
As the 'master' branch of 'lib' is quite heavy-weighted, I do not want to fetch 'master' at all. By using the option '-b light' to specify which branch shall be tracked, there is no need to fetch other branches besides 'light'. I'm not sure if it is really necessary for 'git submodule add' to fetch anything, as this could also be done by a subsequent 'git submodule update'.


Anything else you want to add:
This issue could be related to: https://stackoverflow.com/questions/61483547/how-to-shallow-pull-submodule-that-is-tracked-by-branch-name


[System Info]
git version:
git version 2.29.2.windows.2
cpu: x86_64
built from commit: 3464b98ce6803c98bf8fb34390cd150d66e4a0d3
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
uname: Windows 10.0 17763 
compiler info: gnuc: 10.2
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe


[Enabled Hooks]

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

end of thread, other threads:[~2021-01-08 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06  0:19 [Bug] 'git submodule update --single-branch' still fetching master - -
2021-01-06 19:30 ` Philippe Blain
2021-01-08 14:27   ` - -

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).