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

The argument "--recurse-submodules=no" when doing "fetch --all" is not passed to the following commands which can ends up fetching submodules

From
DLDominick Latreille <dominick.latreille@ubisoft.com>
Date
Feb 9, 2021, 16:35 UTC
Message-ID
<DM5PR1701MB1724CCBB1AC5CF342BA9ADD5898E9@DM5PR1701MB1724.namprd17.prod.outlook.com>
Hi! 
I opened the following issue https://github.com/git-for-windows/git/issues/3027  , but it also happen when using git on Linux. I have been told to send an email here for the issue.

The git version I am using is the following: ``` git version 2.25.1 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 ``` Terminal used : Bash

Here is the command I ran to trigger this issue ``` GIT_TRACE2=1 git fetch --all --recurse-submodules=no ```

I expected the submodules to not be fetched and to see this command with traces activated ``` git fetch --append --no-auto-gc --recurse-submodules=no --no-write-commit-graph origin ```

But, here is the command line I got with traces activated and the submodules were fetched later on. ``` git fetch --append --no-auto-gc --no-write-commit-graph origin ```

Here are some repro steps with a repository on GitHub.
1. Clone with git bash https://github.com/DomLatr/RepoWithSubmodule
2.  In the repo, run the following command : "git submodule update --init"
3. In the file .git\packed-refs, remove the line "f5165dbd5441d97e7fba6b55917a4c7865e5d7ee refs/remotes/origin/change-submodule" to simulate that the repository does not have the branch.
3a. If the line is not present in "packed-refs" or is straight up absent, you can remove the file ".git\refs\remotes\origin\change-submodule", that will have the same result.
4. Run the command : "GIT_TRACE2=1 git fetch --all --recurse-submodules=no"
5. Notice that the submodules **are** fetched since it uses the default value "--recurse-submodules=on-demand" instead of the value passed in the CLI
It happens in a repository with submodules that needs would need to be fetched. The value of "fetch.recurseSubmodules" by default is "on-demand", which translate to "yes" when you need to fetch a new SHA that you don't have locally. I tried the 3 command line possibilities with --recurse-submodules and GIT_TRACE2=1. Here is the following results:

GIT_TRACE2=1 git fetch --all --recurse-submodules=no => git fetch --append --no-auto-gc --no-write-commit-graph origin

GIT_TRACE2=1 git fetch --all --recurse-submodules=on-demand => git fetch --append --no-auto-gc --no-write-commit-graph --recurse-submodules=on-demand origin

GIT_TRACE2=1 git fetch --all --recurse-submodules=yes => git fetch --append --no-auto-gc --no-write-commit-graph --recurse-submodules origin

Since the  "--recurse-submodules=no" is not passed to the following commands that are ran automatically, I can see that it is using the default value of "--recuse-submodules=on-demand", which will end up fetching the submodules in this case.
Thanks!
Dominick
Next: Jeff King
Message 1 of 2 in “The argument "--recurse-submodules=no" when doing "fetch --all" is not passed to the following commands which can ends up fetching submodules”
  1. Dominick LatreilleFeb 9, 2021
  2. Jeff KingFeb 9, 2021

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.