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

[Bug] Behavioral change in git clone --depth=1 --recurse-submodule

From
TPTadeus Prastowo <tadeus.prastowo@praim.com>
Date
Sep 15, 2022, 12:23 UTC
Message-ID
<VI1PR02MB6301891F2C862773918CB659FD499@VI1PR02MB6301.eurprd02.prod.outlook.com>
Hello,
First of all, please keep me in CC as I am not subscribed to the mailing list.
Expected result when using Ubuntu Focal 20.04 LTS:

$ git --version git version 2.25.1 $ git clone --verbose --depth=1 --recurse-submodules=<submodule path> -b <branch name> ssh://<user name>@<server name>/<repo path> Cloning into '<repo name>'... remote: Counting objects: <number A>, done. remote: Compressing objects: 100% (<number B>/<number B>), done. remote: Total <number A> (delta <number F>), reused <number C> (delta <number D>) Receiving objects: 100% (<number A>/<number A>), <number U> MiB | <number V> MiB/s, done. Resolving deltas: 100% (<number F>/<number F>), done. Updating files: 100% (<number G>/<number G>), done. Submodule '<submodule path>' (ssh://<user name>@<server name>/<submodule path>) registered for path '<submodule path>' Cloning into '<submodule absolute path>'... remote: Counting objects: <IMPORTANT A>, done. remote: Compressing objects: 100% (<number H>/<number H>), done. remote: Total <IMPORTANT A> (delta <number I>), reused <number J> (delta <number K>) Receiving objects: 100% (<IMPORTANT A>/<IMPORTANT A>), <number X> MiB | <number Y> MiB/s, done. Resolving deltas: 100% (<number I>/<number I>), done. Submodule path '<submodule path>': checked out '<OID>'

Problem observed when using the same Ubuntu Focal 20.04 LTS machine but using a different working directory:

$ sudo add-apt-repository ppa:git-core/ppa $ sudo aptitude install git $ git --version git version 2.37.3 $ git clone --verbose --depth=1 --recurse-submodules=<submodule path> -b <branch name> ssh://<user name>@<server name>/<repo path> Cloning into '<repo name>'... remote: Counting objects: <number A>, done. remote: Compressing objects: 100% (<number B>/<number B>), done. remote: Total <number A> (delta <number F>), reused <number C> (delta <number D>) Receiving objects: 100% (<number A>/<number A>), <number Q> MiB | <number R> MiB/s, done. Resolving deltas: 100% (<number F>/<number F>), done. Updating files: 100% (<number G>/<number G>), done. Submodule '<submodule path>' (ssh://<user name>@<server name>/<submodule path>) registered for path '<submodule path>' Cloning into '<submodule absolute path>'... remote: Counting objects: <IMPORTANT B>, done. remote: Compressing objects: 100% (<number L>/<number L>), done. remote: Total <IMPORTANT B> (delta <number M>), reused <number N> (delta <number O>) Receiving objects: 100% (<IMPORTANT B>/<IMPORTANT B>), <number W> MiB | <number Z> MiB/s, done. Resolving deltas: 100% (<number M>/<number M>), done. error: Server does not allow request for unadvertised object <OID> fatal: Fetched in submodule path '<submodule path>', but it did not contain <OID>. Direct fetching of that commit failed.

[Analysis of the Problem]

I can see that the number <IMPORTANT A> is also reported when running (regardless of the git version): git clone --verbose --recurse-submodules ssh://<user name>@<server name>/<submodule path>

And, I can see that the number <IMPORTANT B> is also reported when running (regardless of the git version): git clone --verbose --recurse-submodules --single-branch -b master ssh://<user name>@<server name>/<submodule path>

In other words, while git version 2.25.1 respects what the `git-clone' man page says about the option `--recurse-submodules', git version 2.37.3 does not, quoting https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---recurse-submodulesltpathspecgt:
Submodules are initialized and cloned using their default settings. This is equivalent to running git submodule update --init --recursive <pathspec> immediately after the clone is finished.
End quote.
[The Bug]
The option `--recurse-submodules' is no longer equivalent to "running git submodule update --init --recursive <pathspec>" in git version 2.37.3.
Now this report can be regarded as reporting a bug in the documentation, which is correct.
But, it is my desire for this report to be regarded as reporting a bug in git, especially because other people have reported a specific deficiency in git submodule: the branch information given in .gitmodules is not used when git wants to use the option `--single-branch' on a submodule (see https://lore.kernel.org/git/CANNNLMC_XEqjYPOig+pbqrS30dPCTmcDSev6yg+5EEBkJCaaig@mail.gmail.com/ and the StackOverflow answer refered therein https://stackoverflow.com/a/61492323).
In other words, it is my desire to see not only the documentation be fixed but also git submodule to use the branch information specified in .gitmodules when using the option `--single-branch' on a submodule when cloning a repository by specifying the options `--recurse-submodules' and `--depth'.
Thank you.
-- 
Best regards,
Tadeus
Message 1 of 1 in “[Bug] Behavioral change in git clone --depth=1 --recurse-submodule”
  1. Tadeus PrastowoSep 15, 2022

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.