Skip to contentSkip to conversation

doc: --recurse-submodules

PATCH Superseded Damien Robert 4 participants 69 messages Feb 28, 2020 – Apr 16, 2020 Documentation

lore
Share & tools
lore
#0 lore raw

cover doc: --recurse-submodules

This series add some extra documentation on --recurse-submodules.

Damien Robert (4):
doc: list all commands affected by recurse.submodule
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate recurse.submodule completely
doc: be more precise on (fetch|pull).recurseSubmodules

 Documentation/config/fetch.txt     |  6 ++++--
 Documentation/config/push.txt      |  3 +++
 Documentation/config/submodule.txt | 11 +++++++++--
 Documentation/git-reset.txt        |  6 ++++++
 Documentation/git-restore.txt      |  9 +++++++++
 5 files changed, 31 insertions(+), 4 deletions(-)
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#1 lore raw

PATCH 1/4 doc: list all commands affected by recurse.submodule

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

---
 Documentation/config/submodule.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/config/submodule.txt +3 -2
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 
 submodule.recurse::
 	Specifies if commands recurse into submodules by default. This
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
 
 submodule.fetchJobs::
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#2 lore raw

Re: [PATCH 1/4] doc: list all commands affected by recurse.submodule

HI Damien,

The commit title has the option name reversed: it’s submodule.recurse and not recurse.submodule

Quoted 4 lines · Damien Robert

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

Good find.

Quoted 5 lines

---
Documentation/config/submodule.txt | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)

I’d also add the same list to the "Implementation details" section of the gitsubmodules guide [1], which just mentions checkout at the moment.

[1] https://git-scm.com/docs/gitsubmodules#_implementation_details

Quoted 20 lines
Documentation/config/submodule.txt +0 -0
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 

submodule.recurse::
Specifies if commands recurse into submodules by default. This

Documentation/config/submodule.txt +3 -2
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.

Defaults to false.

submodule.fetchJobs::

Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#3 lore raw

Re: [PATCH 1/4] doc: list all commands affected by recurse.submodule

From Philippe Blain, Sun 01 Mar 2020 at 23:43:35 (-0500) :

Quoted 2 lines

I’d also add the same list to the "Implementation details" section of the gitsubmodules guide [1], which just mentions checkout at the moment.

The implementation details section really is about the behaviour of cloning and checkout. So I just added a link to git-config.

#4 lore raw

PATCH 2/4 doc: document --recurse-submodules for reset and restore

In reply to Damien Robert
---
 Documentation/git-reset.txt   | 6 ++++++
 Documentation/git-restore.txt | 9 +++++++++
 2 files changed, 15 insertions(+)
Documentation/git-reset.txt +6 -0
index 932080c55d..838c0f1101 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the content of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.
 --
 
 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/git-restore.txt +9 -0
index 5bf60d4943..b94b2559c7 100644
@@ -107,6 +107,15 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	Using `--recurse-submodules` will update the content of all
+	restored submodules according to the commit recorded in the
+	superproject. Local modifications in a restored submodule are
+	overwritten. If nothing (or `--no-recurse-submodules`) is used, the
+	work trees of submodules will not be updated. Just like
+	linkgit:git-submodule[1], this will detach `HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#5 lore raw

Re: [PATCH 2/4] doc: document --recurse-submodules for reset and restore

Quoted 23 lines · Damien Robert

---
Documentation/git-reset.txt | 6 ++++++
Documentation/git-restore.txt | 9 +++++++++

2 files changed, 15 insertions(+)
Documentation/git-reset.txt +6 -0
index 932080c55d..838c0f1101 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the content of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.
Quoted 1 line

—

From previous testing I had done, when the submodule is modified (either modified content,
new commits or new commits, staged) and git reset is invoked (and so git reset HEAD is assumed), the submodule is only touched if --hard or --merge is given,
i.e. not when --soft, --mixed (the default action) or --keep are given.
So this is in line with this option just coming into play "When the working tree is updated", as you wrote. However I just noticed that according to the doc --merge should abort in that case (I think?), but it does not if --recurse-submodules is given. I don’t know if it’s a doc oversight or a real bug though...

Quoted 7 lines

See "Reset, restore and revert" in linkgit:git[1] for the differences

Documentation/git-restore.txt +0 -0
index 5bf60d4943..b94b2559c7 100644

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 114

Quoted 8 lines
Documentation/git-restore.txt +5 -0
@@ -107,6 +107,15 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	Using `--recurse-submodules` will update the content of all
+	restored submodules according to the commit recorded in the
+	superproject.

I’d phrase it more like so :
If <pathspec> names a submodule and the restore location includes the working tree, the submodule will only be updated if this option is given,
in which case it’s working tree will be restored to the commit recorded in the superproject at the tree-ish given as the restore source.

This makes it clearer that git restore -- submodule does nothing, and one has to say git restore --recurse-submodules -- submodule for the submodule working tree to be updated.

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 118

Quoted 5 lines

Local modifications in a restored submodule are

Documentation/git-restore.txt +4 -0
+	overwritten. If nothing (or `--no-recurse-submodules`) is used, the
+	work trees of submodules will not be updated. Just like
+	linkgit:git-submodule[1], this will detach `HEAD` of the submodule.
+

In fact git submodule does not unconditionally detach the submodules HEAD
(if git submodule update is invoked and a branch is checked out in the submodule that points to the same commit as the one recorded in the superproject, the HEAD is not detached and the branch stays checked out unless --force is given.) So I would instead link to checkout, which does unconditionally detach the submodules HEAD.

Quoted 6 lines

--overlay::
--no-overlay::
In overlay mode, the command never removes files when

Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#6 lore raw

Re: [PATCH 2/4] doc: document --recurse-submodules for reset and restore

From Philippe Blain, Sun 01 Mar 2020 at 23:45:02 (-0500) :

Quoted 7 lines

From previous testing I had done, when the submodule is modified (either modified content, new commits or new commits, staged) and git reset is invoked (and so git reset HEAD is assumed), the submodule is only touched if --hard or --merge is given,
i.e. not when --soft, --mixed (the default action) or --keep are given.
So this is in line with this option just coming into play "When the working tree is updated", as you wrote.

Yes essentially reset.c only update the value of submodule.recurse according to --recurse-submodules. Then it is 'unpack-trees.c' that handle recursive submodules.

Quoted 2 lines

However I just noticed that according to the doc --merge should abort in that case (I think?), but it does not if --recurse-submodules is given. I don’t know if it’s a doc oversight or a real bug though...

Good question...

Quoted 8 lines

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 117

Quoted 2 lines
Documentation/git-restore.txt +2 -0
+	work trees of submodules will not be updated. Just like
+	linkgit:git-submodule[1], this will detach `HEAD` of the submodule.

In fact git submodule does not unconditionally detach the submodules HEAD
(if git submodule update is invoked and a branch is checked out in the submodule that points to the same commit as the one recorded in the superproject, the HEAD is not detached and the branch stays checked out unless --force is given.) So I would instead link to checkout, which does unconditionally detach the submodules HEAD.

Ok. I copied the above line from git-switch[1]. Should I also update it? git-checkout[1] also says that git-submodule will detach HEAD by the way.

#7 lore raw

Re: [PATCH 2/4] doc: document --recurse-submodules for reset and restore

Quoted 12 lines · Damien Robert
Quoted 9 lines

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 117

Quoted 3 lines
Documentation/git-restore.txt +2 -0
+	work trees of submodules will not be updated. Just like
+	linkgit:git-submodule[1], this will detach `HEAD` of the submodule.

In fact git submodule does not unconditionally detach the submodules HEAD
(if git submodule update is invoked and a branch is checked out in the submodule that points to the same commit as the one recorded in the superproject, the HEAD is not detached and the branch stays checked out unless --force is given.) So I would instead link to checkout, which does unconditionally detach the submodules HEAD.

Quoted 2 lines

Ok. I copied the above line from git-switch[1]. Should I also update it? git-checkout[1] also says that git-submodule will detach HEAD by the way.

I would say yes: git-switch(1) should be updated to refer to git-checkout(1) instead of git-submodule(1), and git-checkout(1) should drop the reference to git-submodule(1)
and just say that it will detach the submodule HEAD.
Maybe in a separate patch before this one ?

#8 lore raw

PATCH 3/4 doc: explain how to deactivate recurse.submodule completely

In reply to Damien Robert
---
 Documentation/config/submodule.txt | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/config/submodule.txt +6 -0
index 5962f41ead..f4edc6cad0 100644
@@ -62,6 +62,12 @@ submodule.recurse::
 	applies to all commands that have a `--recurse-submodules` option
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
+	When set to true, it can be deactivated by calling
+	`--no-recurse-submodules`. But note that since `submodule.recurse`
+	also applies to internal calls to git commands (issued by other git
+	commands), adding `--no-recurse-submodules` might not be enough to
+	completely turn off the effect of that config. A solution is to use
+	`git -c submodule.recurse=0` instead.
 	Defaults to false.
 
 submodule.fetchJobs::
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#9 lore raw

Re: [PATCH 3/4] doc: explain how to deactivate recurse.submodule completely

Again, the commit title has the option name backwards :
s/recurse.submodule/submodule.recurse/

Quoted 3 lines · Damien Robert

I think the commit message for this one could be more detailed
(even if it would say something very similar to the text added to the doc).
I think it could be made clearer, for example, that the -c submodule.recurse=0 is
especially useful to deactivate the config when calling commands that do *not* have a --recurse-submodules flag, but that internally call other commands that do support that flag.

Quoted 9 lines

---
Documentation/config/submodule.txt | 6 ++++++

1 file changed, 6 insertions(+)
Documentation/config/submodule.txt +0 -0
index 5962f41ead..f4edc6cad0 100644

Documentation/config/submodule.txt submodule.recurse:: · line 66

Quoted 5 lines
Documentation/config/submodule.txt +2 -0
@@ -62,6 +62,12 @@ submodule.recurse::
 	applies to all commands that have a `--recurse-submodules` option
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
+	When set to true, it can be deactivated by calling
+	`--no-recurse-submodules`.

I’d say "can be deactivated for a specific call by adding --no-recurse-submodules."

Documentation/config/submodule.txt

Quoted 3 lines

But note that since submodule.recurse

Documentation/config/submodule.txt +2 -0
+	also applies to internal calls to git commands (issued by other git
+	commands),

We tend to capitalize "Git" when talking about the system as a whole.

Quoted 4 lines

adding --no-recurse-submodules might not be enough to

Documentation/config/submodule.txt +2 -0
+	completely turn off the effect of that config. A solution is to use
+	`git -c submodule.recurse=0` instead.

Defaults to false.

Personally I’d let "Defaults to false" just after the list of affected commands.

Quoted 5 lines

submodule.fetchJobs::

Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#10 lore raw

PATCH 4/4 doc: be more precise on (fetch|pull).recurseSubmodules

In reply to Damien Robert

The default value also depends on the value of submodule.recurse

---
 Documentation/config/fetch.txt | 6 ++++--
 Documentation/config/push.txt  | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/config/fetch.txt +4 -2
index f11940280f..8f716809f9 100644
@@ -2,10 +2,12 @@ fetch.recurseSubmodules::
 	This option can be either set to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
 	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse at all when set to false. When set to 'on-demand', 
+	fetch and pull will only recurse into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	If not set, it fallbacks to the value of `submodule.recurse`, and
+	if both are not set the default value is 'on-demand'.
 
 fetch.fsckObjects::
 	If it is set to true, git-fetch-pack will check all fetched
Documentation/config/push.txt +3 -0
index 54871f8213..2a5250cf5c 100644
@@ -112,3 +112,6 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, it fallbacks to the value of `submodule.recurse` (where
+	a 'true' value means 'on-demand'), and if both are not set the
+	default value is 'no'.
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#11 lore raw

Re: [PATCH 4/4] doc: be more precise on (fetch|pull).recurseSubmodules

The commit message title mentions fetch and pull but the patch also talks about push, maybe add that to the title ?

Quoted 16 lines · Damien Robert

The default value also depends on the value of submodule.recurse

---
Documentation/config/fetch.txt | 6 ++++--
Documentation/config/push.txt | 3 +++

2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/config/fetch.txt +0 -0
index f11940280f..8f716809f9 100644
@@ -2,10 +2,12 @@ fetch.recurseSubmodules::
 	This option can be either set to a boolean value or to 'on-demand'.

Documentation/config/fetch.txt fetch.recurseSubmodules:: · line 10

Quoted 10 lines
Documentation/config/fetch.txt +4 -2
 	Setting it to a boolean changes the behavior of fetch and pull to
 	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse at all when set to false. When set to 'on-demand', 
+	fetch and pull will only recurse into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	If not set, it fallbacks to the value of `submodule.recurse`, and
+	if both are not set the default value is 'on-demand’.

For such a change to the doc, I’d expect the commit message to point
to the relevant part of the code that supports the behaviour that is being described, or to the specific test that enforces this behaviour (I briefly looked at t5526 but couldn’t spot one). If such a test is missing it would be good to add it.

Quoted 8 lines

fetch.fsckObjects::
If it is set to true, git-fetch-pack will check all fetched

Documentation/config/push.txt +0 -0
index 54871f8213..2a5250cf5c 100644

Documentation/config/push.txt push.recurseSubmodules:: · line 117

Quoted 6 lines
Documentation/config/push.txt +3 -0
@@ -112,3 +112,6 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, it fallbacks to the value of `submodule.recurse` (where
+	a 'true' value means 'on-demand'), and if both are not set the
+	default value is 'no’.

Same thing here. Also, I do not think it’s good UI that setting ‘submodule,recurse’ to true will make ‘push' default to ‘on-demand’ but will make ‘fetch’ unconditionally fetch, but I guess that would be for another series...

Quoted 3 lines
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#12 lore raw
In reply to Damien Robert

Note that git-switch.txt states that
Using --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject.
but actually only 'active' submodules will be updated.

Should I also update the doc? It is already stated in gitsubmodules(7) that only 'active' submodules are considered for recursion.

Signature · 2 lines
Damien Robert
http://www.normalesup.org/~robert/pro
#13 lore raw
Quoted 8 lines · Damien Robert

Note that git-switch.txt states that
Using --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject.
but actually only 'active' submodules will be updated.

Technically that’s true, but I’d say that in a "simple" workflow (you clone a superproject then do git submodule update --init, then maybe set submodule.recurse to true), then being active and being initialized are equivalent. So I don’t think it’s that big of an issue.

In any case, if such a change is made, the doc for
all commands that have the flag should be revised, as both "initialized" (grep, checkout, switch, read-tree) and "populated" (fetch, pull) seems to be used currently.

Quoted 7 lines

Should I also update the doc? It is already stated in gitsubmodules(7) that only 'active' submodules are considered for recursion.

Signature · 2 lines
Damien Robert
http://www.normalesup.org/~robert/pro
#14 lore raw
In reply to Damien Robert

Hi Damien,

Quoted 10 lines · Damien Robert

This series add some extra documentation on --recurse-submodules.

Damien Robert (4):
doc: list all commands affected by recurse.submodule
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate recurse.submodule completely
doc: be more precise on (fetch|pull).recurseSubmodules

Quoted 6 lines
Documentation/config/fetch.txt     |  6 ++++--
Documentation/config/push.txt      |  3 +++
Documentation/config/submodule.txt | 11 +++++++++--
Documentation/git-reset.txt        |  6 ++++++
Documentation/git-restore.txt      |  9 +++++++++
5 files changed, 31 insertions(+), 4 deletions(-)

Thanks a lot for working on that!

Cheers,
Philippe.

Quoted 4 lines
Signature · 2 lines
-- 
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#15 lore raw

v2 cover doc: --recurse-submodules

In reply to Damien Robert

Incorporated the comments of Philippe Blain.

Other changes since v1:
- Patch 4: also updated a little the man page of git fetch and git pull.
- Added a new patch to refer to 'active' submodules.

Damien Robert (5):
doc: list all commands affected by submodule.recurse
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate recurse.submodule completely
doc: be more precise on (fetch|push).recurseSubmodules
doc: --recurse-submodules only apply to active submodules

 Documentation/config/fetch.txt     |  6 ++++--
 Documentation/config/push.txt      |  3 +++
 Documentation/config/submodule.txt | 12 ++++++++++--
 Documentation/fetch-options.txt    |  9 +++++----
 Documentation/git-checkout.txt     |  2 +-
 Documentation/git-grep.txt         |  2 +-
 Documentation/git-pull.txt         |  5 ++---
 Documentation/git-read-tree.txt    |  2 +-
 Documentation/git-reset.txt        |  6 ++++++
 Documentation/git-restore.txt      | 10 ++++++++++
 Documentation/git-switch.txt       |  2 +-
 Documentation/gitsubmodules.txt    |  3 ++-
 12 files changed, 46 insertions(+), 16 deletions(-)
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#16 lore raw

PATCH v2 1/5 doc: list all commands affected by submodule.recurse

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

---
 Documentation/config/submodule.txt | 5 +++--
 Documentation/gitsubmodules.txt    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Documentation/config/submodule.txt +3 -2
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 
 submodule.recurse::
 	Specifies if commands recurse into submodules by default. This
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
 
 submodule.fetchJobs::
Documentation/gitsubmodules.txt +2 -1
index c476f891b5..f9f4e65c9e 100644
@@ -271,7 +271,8 @@ will not be checked out by default; You can instruct 'clone' to recurse
 into submodules. The 'init' and 'update' subcommands of 'git submodule'
 will maintain submodules checked out and at an appropriate revision in
 your working tree. Alternatively you can set 'submodule.recurse' to have
-'checkout' recursing into submodules.
+'checkout' recursing into submodules (note that 'submodule.recurse' also
+affects other git commands, see linkgit:git-config[1] for a complete list).
 
 
 SEE ALSO
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#17 lore raw

PATCH v2 2/5 doc: document --recurse-submodules for reset and restore

In reply to Damien Robert
---
 Documentation/git-reset.txt   |  6 ++++++
 Documentation/git-restore.txt | 10 ++++++++++
 2 files changed, 16 insertions(+)
Documentation/git-reset.txt +6 -0
index 932080c55d..838c0f1101 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the content of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.
 --
 
 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/git-restore.txt +10 -0
index 5bf60d4943..5036f91132 100644
@@ -107,6 +107,16 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names a submodule and the restore location includes
+	the working tree, the submodule will only be updated if this option
+	is given, in which case it's working tree will be restored to the
+	commit recorded in the superproject, and it's local modifications
+	overwritten. If nothing (or `--no-recurse-submodules`) is used,
+	the work trees of submodules will not be updated. Just like
+	linkgit:git-checkout[1], this will detach `HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#18 lore raw

Re: [PATCH v2 2/5] doc: document --recurse-submodules for reset and restore

Review

Quoted 9 lines · Damien Robert
(quoted diff) +8 -0
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+...
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names a submodule and the restore location includes
+...

Hmph, this inconsistency across files is a bit unfortunate.

I think (please somebody correct me from sideways) we have been moving towards using the "--[no-]option-name", so we would want to clean up the latter (together with the "--[no-]overlay" entry in the same file, with which the above tries to be consistent) sometime later when the dust settles, iow, not as a part of this series.

Quoted 9 lines
Documentation/git-restore.txt +6 -0
+	is given, in which case it's working tree will be restored to the
+	commit recorded in the superproject, and it's local modifications
+	overwritten. If nothing (or `--no-recurse-submodules`) is used,
+	the work trees of submodules will not be updated. Just like
+	linkgit:git-checkout[1], this will detach `HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
#19 lore raw

Re: [PATCH v2 2/5] doc: document --recurse-submodules for reset and restore

In reply to Damien Robert
Quoted 23 lines · Damien Robert

---
Documentation/git-reset.txt | 6 ++++++
Documentation/git-restore.txt | 10 ++++++++++

2 files changed, 16 insertions(+)
Documentation/git-reset.txt +6 -0
index 932080c55d..838c0f1101 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the content of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.
Quoted 1 line

—

Maybe "working tree" instead of "content" ?

Quoted 10 lines

See "Reset, restore and revert" in linkgit:git[1] for the differences

Documentation/git-restore.txt +0 -0
index 5bf60d4943..5036f91132 100644
@@ -107,6 +107,16 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 119

Quoted 10 lines
Documentation/git-restore.txt +10 -0
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names a submodule and the restore location includes
+	the working tree, the submodule will only be updated if this option
+	is given, in which case it's working tree will be restored to the
+	commit recorded in the superproject, and it's local modifications
+	overwritten. If nothing (or `--no-recurse-submodules`) is used,
+	the work trees of submodules will not be updated. Just like
+	linkgit:git-checkout[1], this will detach `HEAD` of the submodule.
+

both "it's" should be "its". In fact I'd personally prefer "any local modifications" instead of "its local modifications"

#20 lore raw

PATCH v2 3/5 doc: explain how to deactivate recurse.submodule completely

In reply to Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/config/submodule.txt +7 -0
index 5962f41ead..74e691a487 100644
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated by calling
+	`--no-recurse-submodules`. Note that some Git commands without this
+	option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	since `submodule.recurse`. In this case a solution is to temporary
+	change the configuration value by using `git -c submodule.recurse=0`.
 
 submodule.fetchJobs::
 	Specifies how many submodules are fetched/cloned at the same time.
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#21 lore raw

Re: [PATCH v2 3/5] doc: explain how to deactivate recurse.submodule completely

Quoted 10 lines · Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/config/submodule.txt +0 -0
index 5962f41ead..74e691a487 100644

Documentation/config/submodule.txt submodule.recurse:: · line 67

Quoted 5 lines
Documentation/config/submodule.txt +2 -0
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated by calling
+	`--no-recurse-submodules`. Note that some Git commands without this

You do not "call" an option [*1*]. Perhaps "... can be overriden by passing the --no-recurse-submodules option from the command line."

Documentation/config/submodule.txt submodule.recurse:: · line 72

Quoted 5 lines
Documentation/config/submodule.txt +5 -0
+	option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	since `submodule.recurse`. In this case a solution is to temporary
+	change the configuration value by using `git -c submodule.recurse=0`.

A good piece of advice.

[Footnote]

*1* ... unless you are in a different business, that is ;-).

#22 lore raw

Re: [PATCH v2 3/5] doc: explain how to deactivate recurse.submodule completely

Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Quoted 13 lines

Documentation/config/submodule.txt submodule.recurse:: · line 67

Quoted 10 lines
Documentation/config/submodule.txt +2 -0
index 5962f41ead..74e691a487 100644
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated by calling
+	`--no-recurse-submodules`. Note that some Git commands without this

You do not "call" an option [*1*]. Perhaps "... can be overriden by passing the --no-recurse-submodules option from the command line."

nooooooo ... my biggest gripe with documentation is the unnecessary
use of superfluous words. :-)

simply, "can be deactivated via the '--no-recurse-submodules'
option." no one here's getting paid by the word.

rday

#23 lore raw

Re: [PATCH v2 3/5] doc: explain how to deactivate recurse.submodule completely

In reply to Damien Robert

From Damien Robert, Tue 03 Mar 2020 at 18:07:38 (+0100) :

Documentation/config/submodule.txt submodule.recurse:: · line 71

Quoted 6 lines
Documentation/config/submodule.txt +6 -0
+	When set to true, it can be deactivated by calling
+	`--no-recurse-submodules`. Note that some Git commands without this
+	option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	since `submodule.recurse`. In this case a solution is to temporary
        ^^^^^^^^^^^^^^^^^^^^^^^^^^

Sorry this is a leftover from a previous formulation, I'll clean that up.

Quoted 1 line
Documentation/config/submodule.txt +1 -0
+	change the configuration value by using `git -c submodule.recurse=0`.
#24 lore raw

Re: [PATCH v2 3/5] doc: explain how to deactivate recurse.submodule completely

Quoted 6 lines · Damien Robert

Documentation/config/submodule.txt submodule.recurse:: · line 71

Quoted 2 lines
Documentation/config/submodule.txt +1 -0
+	since `submodule.recurse`. In this case a solution is to temporary
       ^^^^^^^^^^^^^^^^^^^^^^^^^^

Sorry this is a leftover from a previous formulation, I'll clean that up.

Also, the commit title still has the option name reversed:
s/recurse.submodule/submodule.recurse/

#25 lore raw

PATCH v2 4/5 doc: be more precise on (fetch|push).recurseSubmodules

In reply to Damien Robert

The default value also depends on the value of submodule.recurse.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---
 Documentation/config/fetch.txt  | 6 ++++--
 Documentation/config/push.txt   | 3 +++
 Documentation/fetch-options.txt | 3 ++-
 Documentation/git-pull.txt      | 3 +--
 4 files changed, 10 insertions(+), 5 deletions(-)
Documentation/config/fetch.txt +4 -2
index f11940280f..8f716809f9 100644
@@ -2,10 +2,12 @@ fetch.recurseSubmodules::
 	This option can be either set to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
 	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse at all when set to false. When set to 'on-demand', 
+	fetch and pull will only recurse into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	If not set, it fallbacks to the value of `submodule.recurse`, and
+	if both are not set the default value is 'on-demand'.
 
 fetch.fsckObjects::
 	If it is set to true, git-fetch-pack will check all fetched
Documentation/config/push.txt +3 -0
index 54871f8213..2a5250cf5c 100644
@@ -112,3 +112,6 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, it fallbacks to the value of `submodule.recurse` (where
+	a 'true' value means 'on-demand'), and if both are not set the
+	default value is 'no'.
Documentation/fetch-options.txt +2 -1
index a115a1ae0e..58972b1a05 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default this uses the fetch.recurseSubmodules value (see
+	linkgit:git-config), and the default value is 'on-demand'.
 
 -j::
 --jobs=<n>::
Documentation/git-pull.txt +1 -2
index dfb901f8b8..47bc4a7061 100644
@@ -86,8 +86,7 @@ OPTIONS
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
 	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-config[1] and
-	linkgit:gitmodules[5]).
+	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#26 lore raw

Re: [PATCH v2 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 6 lines · Damien Robert
Documentation/config/fetch.txt +0 -0
index f11940280f..8f716809f9 100644
@@ -2,10 +2,12 @@ fetch.recurseSubmodules::
 	This option can be either set to a boolean value or to 'on-demand'.

Documentation/config/fetch.txt fetch.recurseSubmodules:: · line 10

Quoted 10 lines
Documentation/config/fetch.txt +4 -2
 	Setting it to a boolean changes the behavior of fetch and pull to
 	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse at all when set to false. When set to 'on-demand', 
+	fetch and pull will only recurse into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	If not set, it fallbacks to the value of `submodule.recurse`, and
+	if both are not set the default value is 'on-demand'.

I do not think "fallback" is a single-word verb. If you must use the phrase, "it falls back to the value of ...", but I personally prefer to give the simplest case first and then its variants second (i.e. if you do not do anything, this is what you get, and then if you do this thing, this other thing happens).

In other words:

If not set, 'on-demand' is used by default, unless 'submodule.recurse' is set, in which case it is used.

But in this case it is so obvious that it would not be necessary to add ", in which case it is used" at the end.

Documentation/config/push.txt push.recurseSubmodules:: · line 117

Quoted 11 lines
Documentation/config/push.txt +3 -0
index 54871f8213..2a5250cf5c 100644
@@ -112,3 +112,6 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, it fallbacks to the value of `submodule.recurse` (where
+	a 'true' value means 'on-demand'), and if both are not set the
+	default value is 'no'.

Likewise.

Documentation/fetch-options.txt ifndef::git-pull[] · line 167

Quoted 11 lines
Documentation/fetch-options.txt +2 -1
index a115a1ae0e..58972b1a05 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default this uses the fetch.recurseSubmodules value (see
+	linkgit:git-config), and the default value is 'on-demand'.

By default, 'on-demand' is used, unless fetch.recurseSubmodules is set (see linkgit:git-config[1]).

#27 lore raw

Re: [PATCH v2 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 18 lines · Junio C Hamano
Quoted 6 lines · Damien Robert
Documentation/config/fetch.txt +0 -0
index f11940280f..8f716809f9 100644
@@ -2,10 +2,12 @@ fetch.recurseSubmodules::
 	This option can be either set to a boolean value or to 'on-demand'.

Documentation/config/fetch.txt fetch.recurseSubmodules:: · line 10

Quoted 10 lines
Documentation/config/fetch.txt +4 -2
 	Setting it to a boolean changes the behavior of fetch and pull to
 	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse at all when set to false. When set to 'on-demand',
+	fetch and pull will only recurse into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	If not set, it fallbacks to the value of `submodule.recurse`, and
+	if both are not set the default value is 'on-demand'.

missed earlier post ... "either set" should be "set either." also,
adverbs technically *follow* what they qualify, so "unconditionally recusrse" should be "recurse unconditionally" and so on.

it has always been thus.

rday

p.s. avoid use of the word "it" if it's potentially unclear what it refers to. in the above, one reads, "If not set, it falls back ..."

*what* falls back?

#28 lore raw

PATCH v2 5/5 doc: --recurse-submodules only apply to active submodules

In reply to Damien Robert

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

---
 Documentation/fetch-options.txt | 6 +++---
 Documentation/git-checkout.txt  | 2 +-
 Documentation/git-grep.txt      | 2 +-
 Documentation/git-pull.txt      | 2 +-
 Documentation/git-read-tree.txt | 2 +-
 Documentation/git-switch.txt    | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)
Documentation/fetch-options.txt +3 -3
index 58972b1a05..ba33009253 100644
@@ -156,11 +156,11 @@ ifndef::git-pull[]
 
 --recurse-submodules[=yes|on-demand|no]::
 	This option controls if and under what conditions new commits of
-	populated submodules should be fetched too. It can be used as a
+	active submodules should be fetched too. It can be used as a
 	boolean option to completely disable recursion when set to 'no' or to
-	unconditionally recurse into all populated submodules when set to
+	unconditionally recurse into all active submodules when set to
 	'yes', which is the default when this option is used without any
-	value. Use 'on-demand' to only recurse into a populated submodule
+	value. Use 'on-demand' to only recurse into a active submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
 	clone. By default this uses the fetch.recurseSubmodules value (see
Documentation/git-checkout.txt +1 -1
index c8fb995fa7..3be0a28284 100644
@@ -292,7 +292,7 @@ Note that this option uses the no overlay mode by default (see also
 
 --recurse-submodules::
 --no-recurse-submodules::
-	Using `--recurse-submodules` will update the content of all initialized
+	Using `--recurse-submodules` will update the content of all active
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
Documentation/git-grep.txt +1 -1
index ddb6acc025..cdf8e26b47 100644
@@ -93,7 +93,7 @@ OPTIONS
 	with `--no-index`.
 
 --recurse-submodules::
-	Recursively search in each submodule that has been initialized and
+	Recursively search in each submodule that is active and
 	checked out in the repository.  When used in combination with the
 	<tree> option the prefix of all submodule output will be the name of
 	the parent project's <tree> object. This option has no effect
Documentation/git-pull.txt +1 -1
index 47bc4a7061..2285f3729d 100644
@@ -85,7 +85,7 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
+	This option controls if new commits of all active submodules should
 	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
Documentation/git-read-tree.txt +1 -1
index da33f84f33..aab6856341 100644
@@ -116,7 +116,7 @@ OPTIONS
 	located in.
 
 --[no-]recurse-submodules::
-	Using --recurse-submodules will update the content of all initialized
+	Using --recurse-submodules will update the content of all active
 	submodules according to the commit recorded in the superproject by
 	calling read-tree recursively, also setting the submodules HEAD to be
 	detached at that commit.
Documentation/git-switch.txt +1 -1
index 197900363b..337852d86b 100644
@@ -181,7 +181,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 --recurse-submodules::
 --no-recurse-submodules::
 	Using `--recurse-submodules` will update the content of all
-	initialized submodules according to the commit recorded in the
+	active submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
 	used, the work trees of submodules will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
Signature · 1 line
Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
#29 lore raw

Re: [PATCH v2 5/5] doc: --recurse-submodules only apply to active submodules

In the commit title: s/apply/applies

Quoted 6 lines · Damien Robert

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

Initialized, active and populated, as far as I understand, are three different concepts.
- Active is defined in gitsubmodules(7), it only involves the configuration variables 'submodule.active', 'submodule.<name>.active' and 'submodule.<name>.url'. The function submodule.c::is_submodule_active checks that a submodule is active.
- My understanding is that "populated" means that the submodule's working tree is
present (and the gitfile correctly points to the submodule repository),
i.e. either the superproject was cloned with --recurse-submodules, or
the user ran git submodule update --init, or git submodule init [<path>] and git submodule update [<path] separately which populated the submodule working tree.
This does not involve the 3 configuration variables above.
- My understanding is that "initialized" (at least in the context of the man pages involved in this patch) means both "populated" and "active" as defined above, i.e. what git submodule update --init does.

Quoted 10 lines

---

Documentation/fetch-options.txt | 6 +++---
Documentation/git-checkout.txt  | 2 +-
Documentation/git-grep.txt      | 2 +-
Documentation/git-pull.txt      | 2 +-
Documentation/git-read-tree.txt | 2 +-
Documentation/git-switch.txt    | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)

What about ls-files ? builtin/ls-files.c:231 indicates that it does call submodule.c::is_submodule_active, so its doc should also be updated.

Documentation/fetch-options.txt ifndef::git-pull[]

Quoted 6 lines
Documentation/fetch-options.txt +0 -0
index 58972b1a05..ba33009253 100644
@@ -156,11 +156,11 @@ ifndef::git-pull[]

From what I understand of the code, git-fetch really recurses into *populated* submodules,
and does not consult the submodule.active or submodule.<name>.active config settings.
If you look at builtin/fetch.c::cmd_fetch, and the functions it calls, but is_submodule_active is not in the call chain. I tested that setting submodule.<name>.active to false and calling

    git fetch --recurse-submodules=yes

still fetches in the submodule(s). So this should stay as "populated".

Documentation/git-checkout.txt Note that this option uses the no overlay mode by default (see also · line 296

Quoted 13 lines
Documentation/git-checkout.txt +1 -3
index c8fb995fa7..3be0a28284 100644
@@ -292,7 +292,7 @@ Note that this option uses the no overlay mode by default (see also
 
--recurse-submodules::
--no-recurse-submodules::
-	Using `--recurse-submodules` will update the content of all initialized
+	Using `--recurse-submodules` will update the content of all active
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)

That's correct as checkout uses the unpack-trees machinery, which calls submodule_move_head, and submodule_move_head calls is_submodule_active (submodule.c:1894).

Documentation/git-grep.txt OPTIONS · line 98

Quoted 13 lines
Documentation/git-grep.txt +1 -2
index ddb6acc025..cdf8e26b47 100644
@@ -93,7 +93,7 @@ OPTIONS
 	with `--no-index`.
 
--recurse-submodules::
-	Recursively search in each submodule that has been initialized and
+	Recursively search in each submodule that is active and
 	checked out in the repository.  When used in combination with the
 	<tree> option the prefix of all submodule output will be the name of
 	the parent project's <tree> object. This option has no effect

That's correct (builtin/grep.c:423).

Quoted 12 lines
Documentation/git-pull.txt +2 -2
index 47bc4a7061..2285f3729d 100644
@@ -85,7 +85,7 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
--[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
+	This option controls if new commits of all active submodules should
 	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
+
Quoted 1 line

If the checkout is done via rebase, local submodule commits are rebased as well.

That's only partly correct: I tested setting submodule.<name>.active to false and doing

    git pull --recurse-submodules

This does fetches the submodule but does not update its working tree, due to the call to is_submodule_active in prepare_to_clone_next_submodule in builtin/submodule--helper.c

Documentation/git-read-tree.txt OPTIONS · line 121

Quoted 13 lines
Documentation/git-read-tree.txt +1 -2
index da33f84f33..aab6856341 100644
@@ -116,7 +116,7 @@ OPTIONS
 	located in.
 
--[no-]recurse-submodules::
-	Using --recurse-submodules will update the content of all initialized
+	Using --recurse-submodules will update the content of all active
 	submodules according to the commit recorded in the superproject by
 	calling read-tree recursively, also setting the submodules HEAD to be
 	detached at that commit.

read-tree is also in the unpack-trees machinery, so that's correct.

Documentation/git-switch.txt name, the guessing is aborted. You can explicitly give a name with · line 185

Quoted 13 lines
Documentation/git-switch.txt +1 -3
index 197900363b..337852d86b 100644
@@ -181,7 +181,7 @@ name, the guessing is aborted.  You can explicitly give a name with
--recurse-submodules::
--no-recurse-submodules::
 	Using `--recurse-submodules` will update the content of all
-	initialized submodules according to the commit recorded in the
+	active submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
 	used, the work trees of submodules will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the

switch is checkout <branch> under the hood, so that's also correct.

In light of these facts, I think the commit title should be :
doc: --recurse-submodules mostly applies to active submodules

#30 lore raw

Re: [PATCH v2 5/5] doc: --recurse-submodules only apply to active submodules

From Philippe Blain, Thu 05 Mar 2020 at 23:17:54 (-0500) :

Quoted 1 line

In the commit title: s/apply/applies

Oups, missed this one.

Quoted 1 line

Initialized, active and populated, as far as I understand, are three different concepts.

[...]

Quoted 8 lines

From what I understand of the code, git-fetch really recurses into *populated* submodules,
and does not consult the submodule.active or submodule.<name>.active config settings.
If you look at builtin/fetch.c::cmd_fetch, and the functions it calls, but is_submodule_active is not in the call chain. I tested that setting submodule.<name>.active to false and calling

    git fetch --recurse-submodules=yes

still fetches in the submodule(s). So this should stay as "populated".

Thanks for the thorough review! I had tested that git-pull was only updating the worktree of active submodules, but missed that it was still fetching non active submodules.

In light of this I think this is even more important to mention which command affects which submodules in the doc.

Quoted 6 lines

That's only partly correct: I tested setting submodule.<name>.active to false and doing

    git pull --recurse-submodules

This does fetches the submodule but does not update its working tree, due to the call to is_submodule_active in prepare_to_clone_next_submodule in builtin/submodule--helper.c

I still left 'active submodule' here in order to not render the formulation too heavy. Since it is implicit that pull goes through fetch, I hope it is clear that the fetching still involves all populated submodules.

Signature · 2 lines
Damien Robert
http://www.normalesup.org/~robert/pro
#31 lore raw

v3 cover doc: --recurse-submodules

In reply to Damien Robert

This is v3, incorporating all remarks received:
- The typos mistakes mentioned by Robert and Junio.
- The main change is patch 5/5 where I incorporated the nice explanations of Philippe Blain.

Damien Robert (5):
doc: list all commands affected by submodule.recurse
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate submodule.recurse completely
doc: be more precise on (fetch|push).recurseSubmodules
doc: --recurse-submodules mostly only apply to active submodules

 Documentation/config/fetch.txt     | 10 ++++++----
 Documentation/config/push.txt      |  2 ++
 Documentation/config/submodule.txt | 12 ++++++++++--
 Documentation/fetch-options.txt    |  3 ++-
 Documentation/git-checkout.txt     |  2 +-
 Documentation/git-grep.txt         |  2 +-
 Documentation/git-ls-files.txt     |  2 +-
 Documentation/git-pull.txt         |  5 ++---
 Documentation/git-read-tree.txt    |  2 +-
 Documentation/git-reset.txt        |  6 ++++++
 Documentation/git-restore.txt      | 10 ++++++++++
 Documentation/git-switch.txt       |  2 +-
 Documentation/gitsubmodules.txt    |  3 ++-
 13 files changed, 45 insertions(+), 16 deletions(-)
Signature · 1 line
Patched on top of v2.26.0-rc2-27-gbe8661a328 (git version 2.25.2)
#32 lore raw

PATCH v3 1/5 doc: list all commands affected by submodule.recurse

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

---
 Documentation/config/submodule.txt | 5 +++--
 Documentation/gitsubmodules.txt    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Documentation/config/submodule.txt +3 -2
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 
 submodule.recurse::
 	Specifies if commands recurse into submodules by default. This
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
 
 submodule.fetchJobs::
Documentation/gitsubmodules.txt +2 -1
index c476f891b5..f9f4e65c9e 100644
@@ -271,7 +271,8 @@ will not be checked out by default; You can instruct 'clone' to recurse
 into submodules. The 'init' and 'update' subcommands of 'git submodule'
 will maintain submodules checked out and at an appropriate revision in
 your working tree. Alternatively you can set 'submodule.recurse' to have
-'checkout' recursing into submodules.
+'checkout' recursing into submodules (note that 'submodule.recurse' also
+affects other git commands, see linkgit:git-config[1] for a complete list).
 
 
 SEE ALSO
Signature · 1 line
Patched on top of v2.26.0-rc2-27-gbe8661a328 (git version 2.25.2)
#33 lore raw

PATCH v3 2/5 doc: document --recurse-submodules for reset and restore

In reply to Damien Robert
---
 Documentation/git-reset.txt   |  6 ++++++
 Documentation/git-restore.txt | 10 ++++++++++
 2 files changed, 16 insertions(+)
Documentation/git-reset.txt +6 -0
index 932080c55d..c8623cfc34 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.
 --
 
 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/git-restore.txt +10 -0
index 5bf60d4943..47f31d4a0f 100644
@@ -107,6 +107,16 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names a submodule and the restore location includes
+	the working tree, the submodule will only be updated if this option
+	is given, in which case its working tree will be restored to the
+	commit recorded in the superproject, and any local modifications
+	overwritten. If nothing (or `--no-recurse-submodules`) is used,
+	the work trees of submodules will not be updated. Just like
+	linkgit:git-checkout[1], this will detach `HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
Signature · 1 line
Patched on top of v2.26.0-rc2-27-gbe8661a328 (git version 2.25.2)
#34 lore raw

Re: [PATCH v3 2/5] doc: document --recurse-submodules for reset and restore

Quoted 14 lines · Damien Robert

---
Documentation/git-reset.txt | 6 ++++++
Documentation/git-restore.txt | 10 ++++++++++

2 files changed, 16 insertions(+)
Documentation/git-reset.txt +0 -0
index 932080c55d..c8623cfc34 100644

Documentation/git-reset.txt but carries forward unmerged index entries. · line 95

Quoted 9 lines
Documentation/git-reset.txt +6 -0
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.

I *think* that should be "the submodules' HEADs" but I'd prefer that a native speaker confirm.

Quoted 8 lines
Documentation/git-reset.txt +0 -1
--
 

See "Reset, restore and revert" in linkgit:git[1] for the differences

Documentation/git-restore.txt +0 -0
index 5bf60d4943..47f31d4a0f 100644

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 112

Quoted 6 lines
Documentation/git-restore.txt +3 -0
@@ -107,6 +107,16 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names a submodule and the restore location includes

To be consistent with patch 5, I think that should be "names an active submodule". (restore is in the unpack-trees machinery so that would be correct; I checked this behaviour).

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 117

Quoted 5 lines
Documentation/git-restore.txt +5 -0
+	the working tree, the submodule will only be updated if this option
+	is given, in which case its working tree will be restored to the
+	commit recorded in the superproject, and any local modifications
+	overwritten. If nothing (or `--no-recurse-submodules`) is used,
+	the work trees of submodules will not be updated. Just like

For consistency I'd use "working trees" here also, as in the first sentence. In fact I think it would read better as "submodules working trees will not be updated".

#35 lore raw

Re: [PATCH v3 2/5] doc: document --recurse-submodules for reset and restore

From Philippe Blain, Sun 22 Mar 2020 at 18:36:23 (-0400) :

Quoted 7 lines

Documentation/git-reset.txt but carries forward unmerged index entries. · line 95

Quoted 5 lines

+--[no-]recurse-submodules::

Documentation/git-reset.txt +4 -0
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules HEAD to be detached at that commit.

I *think* that should be "the submodules' HEADs" but I'd prefer that a native speaker confirm.

This was copied from read-tree. So I'll update it too in my next reroll.

Quoted 8 lines

Documentation/git-restore.txt in linkgit:git-checkout[1] for details. · line 117

Quoted 5 lines
Documentation/git-restore.txt +5 -0
+	the working tree, the submodule will only be updated if this option
+	is given, in which case its working tree will be restored to the
+	commit recorded in the superproject, and any local modifications
+	overwritten. If nothing (or `--no-recurse-submodules`) is used,
+	the work trees of submodules will not be updated. Just like

For consistency I'd use "working trees" here also, as in the first sentence. In fact I think it would read better as "submodules working trees will not be updated".

Likewise, this was copied from checkout (and switch). I'll update all of them.

Signature · 2 lines
Damien Robert
http://www.normalesup.org/~robert/pro
#36 lore raw

PATCH v3 3/5 doc: explain how to deactivate submodule.recurse completely

In reply to Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/config/submodule.txt +7 -0
index 5962f41ead..900d374385 100644
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated via the
+	`--no-recurse-submodules` option. Note that some Git commands
+	without this option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	In this case a solution is to temporary change the configuration
+	value by using `git -c submodule.recurse=0`.
 
 submodule.fetchJobs::
 	Specifies how many submodules are fetched/cloned at the same time.
Signature · 1 line
Patched on top of v2.26.0-rc2-27-gbe8661a328 (git version 2.25.2)
#37 lore raw

Re: [PATCH v3 3/5] doc: explain how to deactivate submodule.recurse completely

Documentation/config/submodule.txt submodule.recurse:: · line 68

Quoted 6 lines · Damien Robert
Documentation/config/submodule.txt +3 -0
+	When set to true, it can be deactivated via the
+	`--no-recurse-submodules` option. Note that some Git commands
+	without this option may call some of the above commands affected by

For clarity I'd write "some Git commands lacking this option" instead, as "without this option" *could* be interpreted as "invoked without this option".

Documentation/config/submodule.txt submodule.recurse::

Quoted 3 lines
Documentation/config/submodule.txt +3 -0
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	In this case a solution

I'm not sure "solution" is the best word here, maybe:

"For these commands a workaround is to temporarily change the configuration..."

Note: s/temporary/temporarily/

Quoted 2 lines

is to temporary change the configuration

Documentation/config/submodule.txt +1 -0
+	value by using `git -c submodule.recurse=0`.
#38 lore raw

PATCH v3 4/5 doc: be more precise on (fetch|push).recurseSubmodules

In reply to Damien Robert

The default value also depends on the value of submodule.recurse. Use this opportunity to correct some grammar mistakes in Documentation/config/fetch.txt signaled by Robert P. J. Day.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---
 Documentation/config/fetch.txt  | 10 ++++++----
 Documentation/config/push.txt   |  2 ++
 Documentation/fetch-options.txt |  3 ++-
 Documentation/git-pull.txt      |  3 +--
 4 files changed, 11 insertions(+), 7 deletions(-)
Documentation/config/fetch.txt +6 -4
index f11940280f..8778a99fa6 100644
@@ -1,11 +1,13 @@
 fetch.recurseSubmodules::
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option can be set either to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to 'on-demand',
+	fetch and pull will only recurse into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	If not set, 'on-demand' is used by default, unless
+	'submodule.recurse' is set.
 
 fetch.fsckObjects::
 	If it is set to true, git-fetch-pack will check all fetched
Documentation/config/push.txt +2 -0
index 0a7aa322a9..f5e5b38c68 100644
@@ -112,3 +112,5 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, 'no' is used by default, unless 'submodule.recurse' is
+	set (in which case a 'true' value means 'on-demand').
Documentation/fetch-options.txt +2 -1
index a115a1ae0e..b1058d63bc 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default, 'on-demand' is used, unless
+	`fetch.recurseSubmodules` is set (see linkgit:git-config[1]).
 
 -j::
 --jobs=<n>::
Documentation/git-pull.txt +1 -2
index dfb901f8b8..47bc4a7061 100644
@@ -86,8 +86,7 @@ OPTIONS
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
 	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-config[1] and
-	linkgit:gitmodules[5]).
+	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Signature · 1 line
Patched on top of v2.26.0-rc2-27-gbe8661a328 (git version 2.25.2)
#39 lore raw

Re: [PATCH v3 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 11 lines · Damien Robert
Documentation/config/fetch.txt +0 -0
index f11940280f..8778a99fa6 100644
@@ -1,11 +1,13 @@

fetch.recurseSubmodules::

Documentation/config/fetch.txt +1 -1
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option can be set either to a boolean value or to 'on-demand'.
Quoted 1 line

Setting it to a boolean changes the behavior of fetch and pull to

I think in the context of patch 5 maybe it would be good to be careful here, and state that this only affects the underlying "fetch" in "pull", and not the whole pull ?

Documentation/config/fetch.txt line 10

Quoted 10 lines
Documentation/config/fetch.txt +3 -3
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to 'on-demand',
+	fetch and pull will only recurse into a populated submodule

when its superproject retrieves a commit that updates the submodule's reference.

Documentation/config/fetch.txt +2 -0
+	If not set, 'on-demand' is used by default, unless
+	'submodule.recurse' is set.

I know Junio seems to think otherwise, but to me it would be clearer if this would be clearly spelled out:

Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.

#40 lore raw

Re: [PATCH v3 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 7 lines · Philippe Blain
Quoted 3 lines
Documentation/config/fetch.txt +1 -1
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option can be set either to a boolean value or to 'on-demand'.

Setting it to a boolean changes the behavior of fetch and pull to

I think in the context of patch 5 maybe it would be good to be careful here, and state that this only affects the underlying "fetch" in "pull", and not the whole pull ?

Meaning that sub(sub)*modules are fetched but the merge is done only for the top-level superproject? I guess it does not hurt to spell it out. Good suggestion.

Quoted 7 lines

Documentation/config/fetch.txt line 10

Quoted 2 lines
Documentation/config/fetch.txt +2 -0
+	If not set, 'on-demand' is used by default, unless
+	'submodule.recurse' is set.

I know Junio seems to think otherwise, but to me it would be clearer if this would be clearly spelled out:

Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.

Well, between the above two, I'd actually have slight preference to yours, but they both look clear enough to almost the same degree, at least to me.

Thanks.

#41 lore raw

Re: [PATCH v3 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 13 lines · Junio C Hamano
Quoted 7 lines · Philippe Blain
Quoted 3 lines
Documentation/config/fetch.txt +1 -1
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option can be set either to a boolean value or to 'on-demand'.

Setting it to a boolean changes the behavior of fetch and pull to

I think in the context of patch 5 maybe it would be good to be careful here, and state that this only affects the underlying "fetch" in "pull", and not the whole pull ?

Quoted 3 lines

Meaning that sub(sub)*modules are fetched but the merge is done only for the top-level superproject? I guess it does not hurt to spell it out. Good suggestion.

I simply meant that since this option is 'fetch.recurseSubmodules', it applies to the fetching operation done by 'git pull' under the hood, and not to the
"updating the working tree" operation that is also done by git pull if
'--recurse-submodules' is passed to it.

Regarding nested submodules, both operations would recurse down the hierarchy:
the fetching fetches all (nested) populated submodules because of the call to submodule.c::fetch_populated_submodules near the end of builtin/fetch.c::cmd_fetch and the "updating the working tree", which is controlled
by the '--recurse-submodules' flag of 'git pull', updates all active submodules because it spawns 'git submodule update --recursive', (as per rebase_submodules and update_submodules in builtin/pull.c).

#42 lore raw

PATCH v3 5/5 doc: --recurse-submodules mostly only apply to active submodules

In reply to Damien Robert

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

Some terminology:
- Active is defined in gitsubmodules(7), it only involves the configuration variables 'submodule.active', 'submodule.<name>.active' and 'submodule.<name>.url'. The function submodule.c::is_submodule_active checks that a submodule is active.
- Populated means that the submodule's working tree is present (and the gitfile correctly points to the submodule repository), i.e. either the superproject was cloned with --recurse-submodules, or the user ran git submodule update --init, or git submodule init [<path>] and git submodule update [<path] separately which populated the submodule working tree. This does not involve the 3 configuration variables above.
- Initialized (at least in the context of the man pages involved in this patch) means both "populated" and "active" as defined above, i.e. what git submodule update --init does.

The --recurse-submodules option mostly affects submodules. An exception is git fetch where the option affects populated submodules. As a consequence, in git pull the fetch affects populated submodules, but the resulting working tree update only affects active submodules.

In the documentation of git-pull we only refer to active submodules, since it is implicit that the fetching behaviour is governed by the fetch command.

---
 Documentation/git-checkout.txt  | 2 +-
 Documentation/git-grep.txt      | 2 +-
 Documentation/git-ls-files.txt  | 2 +-
 Documentation/git-pull.txt      | 2 +-
 Documentation/git-read-tree.txt | 2 +-
 Documentation/git-switch.txt    | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
Documentation/git-checkout.txt +1 -1
index c8fb995fa7..3be0a28284 100644
@@ -292,7 +292,7 @@ Note that this option uses the no overlay mode by default (see also
 
 --recurse-submodules::
 --no-recurse-submodules::
-	Using `--recurse-submodules` will update the content of all initialized
+	Using `--recurse-submodules` will update the content of all active
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
Documentation/git-grep.txt +1 -1
index ddb6acc025..cdf8e26b47 100644
@@ -93,7 +93,7 @@ OPTIONS
 	with `--no-index`.
 
 --recurse-submodules::
-	Recursively search in each submodule that has been initialized and
+	Recursively search in each submodule that is active and
 	checked out in the repository.  When used in combination with the
 	<tree> option the prefix of all submodule output will be the name of
 	the parent project's <tree> object. This option has no effect
Documentation/git-ls-files.txt +1 -1
index 8461c0e83e..3cb2ebb438 100644
@@ -148,7 +148,7 @@ a space) at the start of each line:
 	top directory.
 
 --recurse-submodules::
-	Recursively calls ls-files on each submodule in the repository.
+	Recursively calls ls-files on each active submodule in the repository.
 	Currently there is only support for the --cached mode.
 
 --abbrev[=<n>]::
Documentation/git-pull.txt +1 -1
index 47bc4a7061..2285f3729d 100644
@@ -85,7 +85,7 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
+	This option controls if new commits of all active submodules should
 	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
Documentation/git-read-tree.txt +1 -1
index da33f84f33..aab6856341 100644
@@ -116,7 +116,7 @@ OPTIONS
 	located in.
 
 --[no-]recurse-submodules::
-	Using --recurse-submodules will update the content of all initialized
+	Using --recurse-submodules will update the content of all active
 	submodules according to the commit recorded in the superproject by
 	calling read-tree recursively, also setting the submodules HEAD to be
 	detached at that commit.
Documentation/git-switch.txt +1 -1
index 197900363b..337852d86b 100644
@@ -181,7 +181,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 --recurse-submodules::
 --no-recurse-submodules::
 	Using `--recurse-submodules` will update the content of all
-	initialized submodules according to the commit recorded in the
+	active submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
 	used, the work trees of submodules will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
Signature · 1 line
Patched on top of v2.26.0-rc2-27-gbe8661a328 (git version 2.25.2)
#43 lore raw

Re: [PATCH v3 5/5] doc: --recurse-submodules mostly only apply to active submodules

Quoted 2 lines

Le 20 mars 2020 à 17:37, Damien Robert <[email protected]> a écrit

in the title, I'd drop the "only"
"mostly only apply" -> "mostly applies"

Quoted 7 lines

:

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

Quoted 10 lines

Some terminology:
- Active is defined in gitsubmodules(7), it only involves the configuration variables 'submodule.active', 'submodule.<name>.active' and 'submodule.<name>.url'. The function submodule.c::is_submodule_active checks that a submodule is active.
- Populated means that the submodule's working tree is present (and the gitfile correctly points to the submodule repository), i.e. either the superproject was cloned with --recurse-submodules, or the user ran git submodule update --init, or git submodule init [<path>] and git submodule update [<path]

missing a closing '>' here (my mistake).

Quoted 8 lines

separately which populated the
submodule working tree. This does not involve the 3 configuration variables above.
- Initialized (at least in the context of the man pages involved in this patch) means both "populated" and "active" as defined above, i.e. what git submodule update --init does.

The --recurse-submodules option mostly affects submodules.

I think you meant "mostly affects active submodules" here, right?

Quoted 8 lines

An exception
is git fetch where the option affects populated submodules. As a consequence, in git pull the fetch affects populated submodules, but the resulting working tree update only affects active submodules.

In the documentation of git-pull we only refer to active submodules, since it is implicit that the fetching behaviour is governed by the fetch command.

This last paragraph is not a description of the current state of the code base, but describes the changes introduced by this patch. As such, it's customary to write it in the imperative mode. A simple suggestion to fix that:

s/we/let's/

Documentation/git-pull.txt OPTIONS · line 88

Quoted 11 lines
Documentation/git-pull.txt +1 -2
index 47bc4a7061..2285f3729d 100644
@@ -85,7 +85,7 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
--[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
+	This option controls if new commits of all active submodules should
 	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).

I understand that the goal here is to make the formulation not too heavy, as you wrote in
https://lore.kernel.org/git/20200320222328.lynvrgqc35pvxxnl@doriath/. However I think the formulation is awkward to begin with : commits are "fetched", but commits are not "updated", the submodules working tree are updated. So maybe:

This option controls if new commits of populated submodules should be fetched, and if the working trees of active submodules should be updated, too

#44 lore raw

v4 cover doc: --recurse-submodules

In reply to Damien Robert

No big changes this time, I just incorporated the latest round of remarks. (A big thanks to Philippe Blain for these!)

Damien Robert (5):
doc: list all commands affected by submodule.recurse
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate submodule.recurse completely
doc: be more precise on (fetch|push).recurseSubmodules
doc: --recurse-submodules mostly applies to active submodules

 Documentation/config/fetch.txt     |  9 +++++----
 Documentation/config/push.txt      |  2 ++
 Documentation/config/submodule.txt | 12 ++++++++++--
 Documentation/fetch-options.txt    |  3 ++-
 Documentation/git-checkout.txt     |  4 ++--
 Documentation/git-grep.txt         |  2 +-
 Documentation/git-ls-files.txt     |  2 +-
 Documentation/git-pull.txt         |  5 +++--
 Documentation/git-read-tree.txt    |  4 ++--
 Documentation/git-reset.txt        |  6 ++++++
 Documentation/git-restore.txt      | 11 +++++++++++
 Documentation/git-switch.txt       |  4 ++--
 Documentation/gitsubmodules.txt    |  3 ++-
 13 files changed, 49 insertions(+), 18 deletions(-)
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#45 lore raw

PATCH v4 1/5 doc: list all commands affected by submodule.recurse

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

---
 Documentation/config/submodule.txt | 5 +++--
 Documentation/gitsubmodules.txt    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Documentation/config/submodule.txt +3 -2
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 
 submodule.recurse::
 	Specifies if commands recurse into submodules by default. This
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
 
 submodule.fetchJobs::
Documentation/gitsubmodules.txt +2 -1
index c476f891b5..f9f4e65c9e 100644
@@ -271,7 +271,8 @@ will not be checked out by default; You can instruct 'clone' to recurse
 into submodules. The 'init' and 'update' subcommands of 'git submodule'
 will maintain submodules checked out and at an appropriate revision in
 your working tree. Alternatively you can set 'submodule.recurse' to have
-'checkout' recursing into submodules.
+'checkout' recursing into submodules (note that 'submodule.recurse' also
+affects other git commands, see linkgit:git-config[1] for a complete list).
 
 
 SEE ALSO
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#46 lore raw

PATCH v4 2/5 doc: document --recurse-submodules for reset and restore

In reply to Damien Robert

Also unify the formulation about --no-submodules for checkout and switch, which we reuse for restore.

And correct the formulation about submodules' HEAD in read-tree, which we reuse in reset.

---
 Documentation/git-checkout.txt  |  2 +-
 Documentation/git-read-tree.txt |  2 +-
 Documentation/git-reset.txt     |  6 ++++++
 Documentation/git-restore.txt   | 11 +++++++++++
 Documentation/git-switch.txt    |  2 +-
 5 files changed, 20 insertions(+), 3 deletions(-)
Documentation/git-checkout.txt +1 -1
index c8fb995fa7..140bd3eabb 100644
@@ -296,7 +296,7 @@ Note that this option uses the no overlay mode by default (see also
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
-	is used, the work trees of submodules will not be updated.
+	is used, submodules working trees will not be updated.
 	Just like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodule.
 
Documentation/git-read-tree.txt +1 -1
index da33f84f33..807cad4691 100644
@@ -118,7 +118,7 @@ OPTIONS
 --[no-]recurse-submodules::
 	Using --recurse-submodules will update the content of all initialized
 	submodules according to the commit recorded in the superproject by
-	calling read-tree recursively, also setting the submodules HEAD to be
+	calling read-tree recursively, also setting the submodules' HEADs to be
 	detached at that commit.
 
 --no-sparse-checkout::
Documentation/git-reset.txt +6 -0
index 932080c55d..d7a09f11a0 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules' HEADs to be detached at that commit.
 --
 
 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/git-restore.txt +11 -0
index 5bf60d4943..8e3b339802 100644
@@ -107,6 +107,17 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names an active submodule and the restore location
+	includes the working tree, the submodule will only be updated if
+	this option is given, in which case its working tree will be
+	restored to the commit recorded in the superproject, and any local
+	modifications overwritten. If nothing (or
+	`--no-recurse-submodules`) is used, submodules working trees will
+	not be updated. Just like linkgit:git-checkout[1], this will detach
+	`HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
Documentation/git-switch.txt +1 -1
index 197900363b..79dbc9624d 100644
@@ -183,7 +183,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 	Using `--recurse-submodules` will update the content of all
 	initialized submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
-	used, the work trees of submodules will not be updated. Just
+	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodules.
 
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#47 lore raw

Re: [PATCH v4 2/5] doc: document --recurse-submodules for reset and restore

Quoted 4 lines · Damien Robert

Also unify the formulation about --no-submodules

that should be '--no-recurse-submodules'

Quoted 33 lines

for checkout and
switch, which we reuse for restore.

And correct the formulation about submodules' HEAD in read-tree, which we reuse in reset.

---

Documentation/git-checkout.txt  |  2 +-
Documentation/git-read-tree.txt |  2 +-
Documentation/git-reset.txt     |  6 ++++++
Documentation/git-restore.txt   | 11 +++++++++++
Documentation/git-switch.txt    |  2 +-
5 files changed, 20 insertions(+), 3 deletions(-)
Documentation/git-checkout.txt +1 -1
index c8fb995fa7..140bd3eabb 100644
@@ -296,7 +296,7 @@ Note that this option uses the no overlay mode by default (see also
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
-	is used, the work trees of submodules will not be updated.
+	is used, submodules working trees will not be updated.
 	Just like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodule.
 
Documentation/git-read-tree.txt +0 -0
index da33f84f33..807cad4691 100644

Documentation/git-read-tree.txt OPTIONS · line 120

Quoted 5 lines
Documentation/git-read-tree.txt +1 -2
@@ -118,7 +118,7 @@ OPTIONS
--[no-]recurse-submodules::
 	Using --recurse-submodules will update the content of all initialized
 	submodules according to the commit recorded in the superproject by
-	calling read-tree recursively, also setting the submodules HEAD to be
+	calling read-tree recursively, also setting the submodules' HEADs to be

I've rethought about that and I think it should be "submodules' HEAD" (sorry!)

Quoted 8 lines
Documentation/git-read-tree.txt +0 -1
 	detached at that commit.
 
--no-sparse-checkout::
Documentation/git-reset.txt +0 -0
index 932080c55d..d7a09f11a0 100644

Documentation/git-reset.txt but carries forward unmerged index entries. · line 95

Quoted 9 lines
Documentation/git-reset.txt +6 -0
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules' HEADs to be detached at that commit.

same here

Quoted 41 lines
Documentation/git-reset.txt +0 -1
--
 

See "Reset, restore and revert" in linkgit:git[1] for the differences

Documentation/git-restore.txt +11 -2
index 5bf60d4943..8e3b339802 100644
@@ -107,6 +107,17 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names an active submodule and the restore location
+	includes the working tree, the submodule will only be updated if
+	this option is given, in which case its working tree will be
+	restored to the commit recorded in the superproject, and any local
+	modifications overwritten. If nothing (or
+	`--no-recurse-submodules`) is used, submodules working trees will
+	not be updated. Just like linkgit:git-checkout[1], this will detach
+	`HEAD` of the submodule.
+
--overlay::
--no-overlay::
 	In overlay mode, the command never removes files when
Documentation/git-switch.txt +1 -1
index 197900363b..79dbc9624d 100644
@@ -183,7 +183,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 	Using `--recurse-submodules` will update the content of all
 	initialized submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
-	used, the work trees of submodules will not be updated. Just
+	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodules.
 
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#48 lore raw

PATCH v4 3/5 doc: explain how to deactivate submodule.recurse completely

In reply to Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/config/submodule.txt +7 -0
index 5962f41ead..d7a63c8c12 100644
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated via the
+	`--no-recurse-submodules` option. Note that some Git commands
+	lacking this option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	For these commands a workaround is to temporarily change the
+	configuration value by using `git -c submodule.recurse=0`.
 
 submodule.fetchJobs::
 	Specifies how many submodules are fetched/cloned at the same time.
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#49 lore raw

PATCH v4 4/5 doc: be more precise on (fetch|push).recurseSubmodules

In reply to Damien Robert

The default value also depends on the value of submodule.recurse. Use this opportunity to correct some grammar mistakes in Documentation/config/fetch.txt signaled by Robert P. J. Day.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---
 Documentation/config/fetch.txt  | 9 +++++----
 Documentation/config/push.txt   | 2 ++
 Documentation/fetch-options.txt | 3 ++-
 Documentation/git-pull.txt      | 3 +--
 4 files changed, 10 insertions(+), 7 deletions(-)
Documentation/config/fetch.txt +5 -4
index f11940280f..cd5b1417c4 100644
@@ -1,11 +1,12 @@
 fetch.recurseSubmodules::
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option can be set either to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to 'on-demand',
+	fetch and pull will only recurse fetching into a populated submodule
 	when its superproject retrieves a commit that updates the submodule's
 	reference.
+	Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.
 
 fetch.fsckObjects::
 	If it is set to true, git-fetch-pack will check all fetched
Documentation/config/push.txt +2 -0
index 0a7aa322a9..f5e5b38c68 100644
@@ -112,3 +112,5 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, 'no' is used by default, unless 'submodule.recurse' is
+	set (in which case a 'true' value means 'on-demand').
Documentation/fetch-options.txt +2 -1
index a115a1ae0e..b1058d63bc 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default, 'on-demand' is used, unless
+	`fetch.recurseSubmodules` is set (see linkgit:git-config[1]).
 
 -j::
 --jobs=<n>::
Documentation/git-pull.txt +1 -2
index dfb901f8b8..47bc4a7061 100644
@@ -86,8 +86,7 @@ OPTIONS
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
 	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-config[1] and
-	linkgit:gitmodules[5]).
+	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#50 lore raw

Re: [PATCH v4 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 31 lines · Damien Robert

The default value also depends on the value of submodule.recurse. Use this opportunity to correct some grammar mistakes in Documentation/config/fetch.txt signaled by Robert P. J. Day.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---

Documentation/config/fetch.txt  | 9 +++++----
Documentation/config/push.txt   | 2 ++
Documentation/fetch-options.txt | 3 ++-
Documentation/git-pull.txt      | 3 +--
4 files changed, 10 insertions(+), 7 deletions(-)
Documentation/config/fetch.txt +0 -0
index f11940280f..cd5b1417c4 100644
@@ -1,11 +1,12 @@

fetch.recurseSubmodules::

Documentation/config/fetch.txt +1 -1
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option can be set either to a boolean value or to 'on-demand'.

Setting it to a boolean changes the behavior of fetch and pull to

Documentation/config/fetch.txt line 6

Quoted 6 lines
Documentation/config/fetch.txt +3 -3
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to 'on-demand',
+	fetch and pull will only recurse fetching into a populated submodule

The chosen formulation seems to imply that only for "on-demand" will fetch and pull recursively *fetch* in submodules, which is misleading. I think it might be clearer to just add a sentence at the start :

This option controls whether git fetch (and the underlying fetch in git pull) will recursively fetch into populated submodules.
This option can be set either to a boolean value or to 'on-demand'.
Setting it to a boolean changes the behavior of fetch and pull to recurse unconditionally into submodules when set to true or to not recurse at all when set to false. When set to on-demand, fetch and pull will only recurse into a populated submodule when its superproject retrieves a commit that updates the submodule’s reference.

Quoted 47 lines

when its superproject retrieves a commit that updates the submodule's reference.

Documentation/config/fetch.txt +1 -0
+	Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.

fetch.fsckObjects::
If it is set to true, git-fetch-pack will check all fetched

Documentation/config/push.txt +2 -0
index 0a7aa322a9..f5e5b38c68 100644
@@ -112,3 +112,5 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, 'no' is used by default, unless 'submodule.recurse' is
+	set (in which case a 'true' value means 'on-demand').
Documentation/fetch-options.txt +2 -3
index a115a1ae0e..b1058d63bc 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default, 'on-demand' is used, unless
+	`fetch.recurseSubmodules` is set (see linkgit:git-config[1]).
 
-j::
--jobs=<n>::
Documentation/git-pull.txt +2 -3
index dfb901f8b8..47bc4a7061 100644
@@ -86,8 +86,7 @@ OPTIONS
 
--[no-]recurse-submodules[=yes|on-demand|no]::
 	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-config[1] and
-	linkgit:gitmodules[5]).
+	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
+

If the checkout is done via rebase, local submodule commits are rebased as well. +

Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#51 lore raw

PATCH v4 5/5 doc: --recurse-submodules mostly applies to active submodules

In reply to Damien Robert

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

Some terminology:
- Active is defined in gitsubmodules(7), it only involves the configuration variables 'submodule.active', 'submodule.<name>.active' and 'submodule.<name>.url'. The function submodule.c::is_submodule_active checks that a submodule is active.
- Populated means that the submodule's working tree is present (and the gitfile correctly points to the submodule repository), i.e. either the superproject was cloned with --recurse-submodules, or the user ran git submodule update --init, or git submodule init [<path>] and git submodule update [<path>] separately which populated the submodule working tree. This does not involve the 3 configuration variables above.
- Initialized (at least in the context of the man pages involved in this patch) means both "populated" and "active" as defined above, i.e. what git submodule update --init does.

The --recurse-submodules option mostly affects active submodules. An exception is git fetch where the option affects populated submodules. As a consequence, in git pull --recurse-submodules the fetch affects populated submodules, but the resulting working tree update only affects active submodules.

In the documentation of git-pull, let's distinguish between the fetching part which affects populated submodules, and the updating of worktrees, which only affects active submodules.

---
 Documentation/git-checkout.txt  | 2 +-
 Documentation/git-grep.txt      | 2 +-
 Documentation/git-ls-files.txt  | 2 +-
 Documentation/git-pull.txt      | 6 ++++--
 Documentation/git-read-tree.txt | 2 +-
 Documentation/git-switch.txt    | 2 +-
 6 files changed, 9 insertions(+), 7 deletions(-)
Documentation/git-checkout.txt +1 -1
index 140bd3eabb..5b697eee1b 100644
@@ -292,7 +292,7 @@ Note that this option uses the no overlay mode by default (see also
 
 --recurse-submodules::
 --no-recurse-submodules::
-	Using `--recurse-submodules` will update the content of all initialized
+	Using `--recurse-submodules` will update the content of all active
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
Documentation/git-grep.txt +1 -1
index ddb6acc025..cdf8e26b47 100644
@@ -93,7 +93,7 @@ OPTIONS
 	with `--no-index`.
 
 --recurse-submodules::
-	Recursively search in each submodule that has been initialized and
+	Recursively search in each submodule that is active and
 	checked out in the repository.  When used in combination with the
 	<tree> option the prefix of all submodule output will be the name of
 	the parent project's <tree> object. This option has no effect
Documentation/git-ls-files.txt +1 -1
index 8461c0e83e..3cb2ebb438 100644
@@ -148,7 +148,7 @@ a space) at the start of each line:
 	top directory.
 
 --recurse-submodules::
-	Recursively calls ls-files on each submodule in the repository.
+	Recursively calls ls-files on each active submodule in the repository.
 	Currently there is only support for the --cached mode.
 
 --abbrev[=<n>]::
Documentation/git-pull.txt +4 -2
index 47bc4a7061..b336df00c7 100644
@@ -85,8 +85,10 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
+	This option controls if new commits of populated submodules should
+	be fetched, and if the working trees of active submodules should be
+	updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and
+	linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Documentation/git-read-tree.txt +1 -1
index 807cad4691..a2350994ee 100644
@@ -116,7 +116,7 @@ OPTIONS
 	located in.
 
 --[no-]recurse-submodules::
-	Using --recurse-submodules will update the content of all initialized
+	Using --recurse-submodules will update the content of all active
 	submodules according to the commit recorded in the superproject by
 	calling read-tree recursively, also setting the submodules' HEADs to be
 	detached at that commit.
Documentation/git-switch.txt +1 -1
index 79dbc9624d..3759c3a265 100644
@@ -181,7 +181,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 --recurse-submodules::
 --no-recurse-submodules::
 	Using `--recurse-submodules` will update the content of all
-	initialized submodules according to the commit recorded in the
+	active submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
 	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
Signature · 1 line
Patched on top of v2.26.0 (git version 2.25.2)
#52 lore raw

v5 cover doc: --recurse-submodules

In reply to Damien Robert

Sorry it took me a while, I have been busy.
I incorporated the two remarks by Philippe Blain on v4.

We are converging!

Damien Robert (5):
doc: list all commands affected by submodule.recurse
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate submodule.recurse completely
doc: be more precise on (fetch|push).recurseSubmodules
doc: --recurse-submodules mostly applies to active submodules

 Documentation/config/fetch.txt     | 13 ++++++++-----
 Documentation/config/push.txt      |  2 ++
 Documentation/config/submodule.txt | 12 ++++++++++--
 Documentation/fetch-options.txt    |  3 ++-
 Documentation/git-checkout.txt     |  4 ++--
 Documentation/git-grep.txt         |  2 +-
 Documentation/git-ls-files.txt     |  2 +-
 Documentation/git-pull.txt         |  5 +++--
 Documentation/git-read-tree.txt    |  4 ++--
 Documentation/git-reset.txt        |  6 ++++++
 Documentation/git-restore.txt      | 11 +++++++++++
 Documentation/git-switch.txt       |  4 ++--
 Documentation/gitsubmodules.txt    |  3 ++-
 13 files changed, 52 insertions(+), 19 deletions(-)
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#53 lore raw

PATCH v5 1/5 doc: list all commands affected by submodule.recurse

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

---
 Documentation/config/submodule.txt | 5 +++--
 Documentation/gitsubmodules.txt    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Documentation/config/submodule.txt +3 -2
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 
 submodule.recurse::
 	Specifies if commands recurse into submodules by default. This
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
 
 submodule.fetchJobs::
Documentation/gitsubmodules.txt +2 -1
index c476f891b5..f9f4e65c9e 100644
@@ -271,7 +271,8 @@ will not be checked out by default; You can instruct 'clone' to recurse
 into submodules. The 'init' and 'update' subcommands of 'git submodule'
 will maintain submodules checked out and at an appropriate revision in
 your working tree. Alternatively you can set 'submodule.recurse' to have
-'checkout' recursing into submodules.
+'checkout' recursing into submodules (note that 'submodule.recurse' also
+affects other git commands, see linkgit:git-config[1] for a complete list).
 
 
 SEE ALSO
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#54 lore raw

PATCH v5 2/5 doc: document --recurse-submodules for reset and restore

In reply to Damien Robert

Also unify the formulation about --no-recurse-submodules for checkout and switch, which we reuse for restore.

And correct the formulation about submodules' HEAD in read-tree, which we reuse in reset.

---
 Documentation/git-checkout.txt  |  2 +-
 Documentation/git-read-tree.txt |  2 +-
 Documentation/git-reset.txt     |  6 ++++++
 Documentation/git-restore.txt   | 11 +++++++++++
 Documentation/git-switch.txt    |  2 +-
 5 files changed, 20 insertions(+), 3 deletions(-)
Documentation/git-checkout.txt +1 -1
index c8fb995fa7..140bd3eabb 100644
@@ -296,7 +296,7 @@ Note that this option uses the no overlay mode by default (see also
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
-	is used, the work trees of submodules will not be updated.
+	is used, submodules working trees will not be updated.
 	Just like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodule.
 
Documentation/git-read-tree.txt +1 -1
index da33f84f33..501f2ec375 100644
@@ -118,7 +118,7 @@ OPTIONS
 --[no-]recurse-submodules::
 	Using --recurse-submodules will update the content of all initialized
 	submodules according to the commit recorded in the superproject by
-	calling read-tree recursively, also setting the submodules HEAD to be
+	calling read-tree recursively, also setting the submodules' HEAD to be
 	detached at that commit.
 
 --no-sparse-checkout::
Documentation/git-reset.txt +6 -0
index 932080c55d..252e2d4e47 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules' HEAD to be detached at that commit.
 --
 
 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/git-restore.txt +11 -0
index 5bf60d4943..8e3b339802 100644
@@ -107,6 +107,17 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names an active submodule and the restore location
+	includes the working tree, the submodule will only be updated if
+	this option is given, in which case its working tree will be
+	restored to the commit recorded in the superproject, and any local
+	modifications overwritten. If nothing (or
+	`--no-recurse-submodules`) is used, submodules working trees will
+	not be updated. Just like linkgit:git-checkout[1], this will detach
+	`HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
Documentation/git-switch.txt +1 -1
index 197900363b..79dbc9624d 100644
@@ -183,7 +183,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 	Using `--recurse-submodules` will update the content of all
 	initialized submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
-	used, the work trees of submodules will not be updated. Just
+	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodules.
 
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#55 lore raw

PATCH v5 3/5 doc: explain how to deactivate submodule.recurse completely

In reply to Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/config/submodule.txt +7 -0
index 5962f41ead..d7a63c8c12 100644
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated via the
+	`--no-recurse-submodules` option. Note that some Git commands
+	lacking this option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	For these commands a workaround is to temporarily change the
+	configuration value by using `git -c submodule.recurse=0`.
 
 submodule.fetchJobs::
 	Specifies how many submodules are fetched/cloned at the same time.
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#56 lore raw

PATCH v5 4/5 doc: be more precise on (fetch|push).recurseSubmodules

In reply to Damien Robert

The default value also depends on the value of submodule.recurse. Use this opportunity to correct some grammar mistakes in Documentation/config/fetch.txt signaled by Robert P. J. Day.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---
 Documentation/config/fetch.txt  | 13 ++++++++-----
 Documentation/config/push.txt   |  2 ++
 Documentation/fetch-options.txt |  3 ++-
 Documentation/git-pull.txt      |  3 +--
 4 files changed, 13 insertions(+), 8 deletions(-)
Documentation/config/fetch.txt +8 -5
index f11940280f..4114af4b3b 100644
@@ -1,11 +1,14 @@
 fetch.recurseSubmodules::
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option controls whether `git fetch` (and the underlying fetch
+	in `git pull`) will recursively fetch into populated submodules.
+	This option can be set either to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
-	when its superproject retrieves a commit that updates the submodule's
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to on-demand, fetch and
+	pull will only recurse into a populated submodule when its
+	superproject retrieves a commit that updates the submodule's
 	reference.
+	Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.
 
 fetch.fsckObjects::
 	If it is set to true, git-fetch-pack will check all fetched
Documentation/config/push.txt +2 -0
index 0a7aa322a9..f5e5b38c68 100644
@@ -112,3 +112,5 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, 'no' is used by default, unless 'submodule.recurse' is
+	set (in which case a 'true' value means 'on-demand').
Documentation/fetch-options.txt +2 -1
index 00d03ec8c3..833f935cd0 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default, 'on-demand' is used, unless
+	`fetch.recurseSubmodules` is set (see linkgit:git-config[1]).
 endif::git-pull[]
 
 -j::
Documentation/git-pull.txt +1 -2
index dfb901f8b8..47bc4a7061 100644
@@ -86,8 +86,7 @@ OPTIONS
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
 	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-config[1] and
-	linkgit:gitmodules[5]).
+	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#57 lore raw

Re: [PATCH v5 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 26 lines · Damien Robert

The default value also depends on the value of submodule.recurse. Use this opportunity to correct some grammar mistakes in Documentation/config/fetch.txt signaled by Robert P. J. Day.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---
 Documentation/config/fetch.txt  | 13 ++++++++-----
 Documentation/config/push.txt   |  2 ++
 Documentation/fetch-options.txt |  3 ++-
 Documentation/git-pull.txt      |  3 +--
 4 files changed, 13 insertions(+), 8 deletions(-)
Documentation/config/fetch.txt +0 -1
index f11940280f..4114af4b3b 100644
@@ -1,11 +1,14 @@
 fetch.recurseSubmodules::
-	This option can be either set to a boolean value or to 'on-demand'.

Documentation/config/fetch.txt line 7

Quoted 10 lines
Documentation/config/fetch.txt +5 -4
+	This option controls whether `git fetch` (and the underlying fetch
+	in `git pull`) will recursively fetch into populated submodules.
+	This option can be set either to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
-	when its superproject retrieves a commit that updates the submodule's
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to on-demand, fetch and

Why did you lose quotes around on-demand on this line? Shouldn't it be typeset the same way as the other one in the sentence "Defaults to ..."?

Quoted 4 lines
Documentation/config/fetch.txt +3 -0
+	pull will only recurse into a populated submodule when its
+	superproject retrieves a commit that updates the submodule's
 	reference.
+	Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.
#58 lore raw

Re: [PATCH v5 4/5] doc: be more precise on (fetch|push).recurseSubmodules

From Junio C Hamano, Sun 05 Apr 2020 at 14:57:22 (-0700) :

Quoted 3 lines

Why did you lose quotes around on-demand on this line? Shouldn't it be typeset the same way as the other one in the sentence "Defaults to ..."?

Yes it should, sorry it's my mistake, I'll send a new version.

#59 lore raw

Re: [PATCH v5 4/5] doc: be more precise on (fetch|push).recurseSubmodules

Quoted 6 lines · Damien Robert

From Junio C Hamano, Sun 05 Apr 2020 at 14:57:22 (-0700) :

Quoted 3 lines

Why did you lose quotes around on-demand on this line? Shouldn't it be typeset the same way as the other one in the sentence "Defaults to ..."?

Yes it should, sorry it's my mistake, I'll send a new version.

Thanks. You may want to wait a bit so that (1) others can spot similar mistakes, if any, in the version on the list and (2) you yourself find some similar errors while waiting for others.

#60 lore raw

Re: [PATCH v5 4/5] doc: be more precise on (fetch|push).recurseSubmodules

From Junio C Hamano, Mon 06 Apr 2020 at 10:56:49 (-0700) :

Quoted 3 lines

Thanks. You may want to wait a bit so that (1) others can spot similar mistakes, if any, in the version on the list and (2) you yourself find some similar errors while waiting for others.

Well this was mainly the only change compared to v4 which was sent 10 days ago. This change was suggested by Philippe Blain, so it has already been read by him, me, you, and then me again when I sent v6 and checked carefully I did not miss another quote around 'on-demand'.

Hopefully that will be enough :)

#61 lore raw

PATCH v5 5/5 doc: --recurse-submodules mostly applies to active submodules

In reply to Damien Robert

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

Some terminology:
- Active is defined in gitsubmodules(7), it only involves the configuration variables 'submodule.active', 'submodule.<name>.active' and 'submodule.<name>.url'. The function submodule.c::is_submodule_active checks that a submodule is active.
- Populated means that the submodule's working tree is present (and the gitfile correctly points to the submodule repository), i.e. either the superproject was cloned with --recurse-submodules, or the user ran git submodule update --init, or git submodule init [<path>] and git submodule update [<path>] separately which populated the submodule working tree. This does not involve the 3 configuration variables above.
- Initialized (at least in the context of the man pages involved in this patch) means both "populated" and "active" as defined above, i.e. what git submodule update --init does.

The --recurse-submodules option mostly affects active submodules. An exception is git fetch where the option affects populated submodules. As a consequence, in git pull --recurse-submodules the fetch affects populated submodules, but the resulting working tree update only affects active submodules.

In the documentation of git-pull, let's distinguish between the fetching part which affects populated submodules, and the updating of worktrees, which only affects active submodules.

---
 Documentation/git-checkout.txt  | 2 +-
 Documentation/git-grep.txt      | 2 +-
 Documentation/git-ls-files.txt  | 2 +-
 Documentation/git-pull.txt      | 6 ++++--
 Documentation/git-read-tree.txt | 2 +-
 Documentation/git-switch.txt    | 2 +-
 6 files changed, 9 insertions(+), 7 deletions(-)
Documentation/git-checkout.txt +1 -1
index 140bd3eabb..5b697eee1b 100644
@@ -292,7 +292,7 @@ Note that this option uses the no overlay mode by default (see also
 
 --recurse-submodules::
 --no-recurse-submodules::
-	Using `--recurse-submodules` will update the content of all initialized
+	Using `--recurse-submodules` will update the content of all active
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
Documentation/git-grep.txt +1 -1
index ddb6acc025..cdf8e26b47 100644
@@ -93,7 +93,7 @@ OPTIONS
 	with `--no-index`.
 
 --recurse-submodules::
-	Recursively search in each submodule that has been initialized and
+	Recursively search in each submodule that is active and
 	checked out in the repository.  When used in combination with the
 	<tree> option the prefix of all submodule output will be the name of
 	the parent project's <tree> object. This option has no effect
Documentation/git-ls-files.txt +1 -1
index 8461c0e83e..3cb2ebb438 100644
@@ -148,7 +148,7 @@ a space) at the start of each line:
 	top directory.
 
 --recurse-submodules::
-	Recursively calls ls-files on each submodule in the repository.
+	Recursively calls ls-files on each active submodule in the repository.
 	Currently there is only support for the --cached mode.
 
 --abbrev[=<n>]::
Documentation/git-pull.txt +4 -2
index 47bc4a7061..b336df00c7 100644
@@ -85,8 +85,10 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
+	This option controls if new commits of populated submodules should
+	be fetched, and if the working trees of active submodules should be
+	updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and
+	linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Documentation/git-read-tree.txt +1 -1
index 501f2ec375..5fa8bab64c 100644
@@ -116,7 +116,7 @@ OPTIONS
 	located in.
 
 --[no-]recurse-submodules::
-	Using --recurse-submodules will update the content of all initialized
+	Using --recurse-submodules will update the content of all active
 	submodules according to the commit recorded in the superproject by
 	calling read-tree recursively, also setting the submodules' HEAD to be
 	detached at that commit.
Documentation/git-switch.txt +1 -1
index 79dbc9624d..3759c3a265 100644
@@ -181,7 +181,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 --recurse-submodules::
 --no-recurse-submodules::
 	Using `--recurse-submodules` will update the content of all
-	initialized submodules according to the commit recorded in the
+	active submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
 	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#62 lore raw

v6 cover doc: --recurse-submodules

In reply to Damien Robert

Fix typo mentioned by Junio.

Damien Robert (5):
doc: list all commands affected by submodule.recurse
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate submodule.recurse completely
doc: be more precise on (fetch|push).recurseSubmodules
doc: --recurse-submodules mostly applies to active submodules

 Documentation/config/fetch.txt     | 13 ++++++++-----
 Documentation/config/push.txt      |  2 ++
 Documentation/config/submodule.txt | 12 ++++++++++--
 Documentation/fetch-options.txt    |  3 ++-
 Documentation/git-checkout.txt     |  4 ++--
 Documentation/git-grep.txt         |  2 +-
 Documentation/git-ls-files.txt     |  2 +-
 Documentation/git-pull.txt         |  5 +++--
 Documentation/git-read-tree.txt    |  4 ++--
 Documentation/git-reset.txt        |  6 ++++++
 Documentation/git-restore.txt      | 11 +++++++++++
 Documentation/git-switch.txt       |  4 ++--
 Documentation/gitsubmodules.txt    |  3 ++-
 13 files changed, 52 insertions(+), 19 deletions(-)
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#63 lore raw

PATCH v6 1/5 doc: list all commands affected by submodule.recurse

Note that ls-files is not affected, even though it has a --recurse-submodules option, so list it as an exception too.

---
 Documentation/config/submodule.txt | 5 +++--
 Documentation/gitsubmodules.txt    | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)
Documentation/config/submodule.txt +3 -2
index b33177151c..5962f41ead 100644
@@ -59,8 +59,9 @@ submodule.active::
 
 submodule.recurse::
 	Specifies if commands recurse into submodules by default. This
-	applies to all commands that have a `--recurse-submodules` option,
-	except `clone`.
+	applies to all commands that have a `--recurse-submodules` option
+	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
+	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
 
 submodule.fetchJobs::
Documentation/gitsubmodules.txt +2 -1
index c476f891b5..f9f4e65c9e 100644
@@ -271,7 +271,8 @@ will not be checked out by default; You can instruct 'clone' to recurse
 into submodules. The 'init' and 'update' subcommands of 'git submodule'
 will maintain submodules checked out and at an appropriate revision in
 your working tree. Alternatively you can set 'submodule.recurse' to have
-'checkout' recursing into submodules.
+'checkout' recursing into submodules (note that 'submodule.recurse' also
+affects other git commands, see linkgit:git-config[1] for a complete list).
 
 
 SEE ALSO
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#64 lore raw

PATCH v6 2/5 doc: document --recurse-submodules for reset and restore

In reply to Damien Robert

Also unify the formulation about --no-recurse-submodules for checkout and switch, which we reuse for restore.

And correct the formulation about submodules' HEAD in read-tree, which we reuse in reset.

---
 Documentation/git-checkout.txt  |  2 +-
 Documentation/git-read-tree.txt |  2 +-
 Documentation/git-reset.txt     |  6 ++++++
 Documentation/git-restore.txt   | 11 +++++++++++
 Documentation/git-switch.txt    |  2 +-
 5 files changed, 20 insertions(+), 3 deletions(-)
Documentation/git-checkout.txt +1 -1
index c8fb995fa7..140bd3eabb 100644
@@ -296,7 +296,7 @@ Note that this option uses the no overlay mode by default (see also
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
-	is used, the work trees of submodules will not be updated.
+	is used, submodules working trees will not be updated.
 	Just like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodule.
 
Documentation/git-read-tree.txt +1 -1
index da33f84f33..501f2ec375 100644
@@ -118,7 +118,7 @@ OPTIONS
 --[no-]recurse-submodules::
 	Using --recurse-submodules will update the content of all initialized
 	submodules according to the commit recorded in the superproject by
-	calling read-tree recursively, also setting the submodules HEAD to be
+	calling read-tree recursively, also setting the submodules' HEAD to be
 	detached at that commit.
 
 --no-sparse-checkout::
Documentation/git-reset.txt +6 -0
index 932080c55d..252e2d4e47 100644
@@ -87,6 +87,12 @@ but carries forward unmerged index entries.
 	different between `<commit>` and `HEAD`.
 	If a file that is different between `<commit>` and `HEAD` has local
 	changes, reset is aborted.
+
+--[no-]recurse-submodules::
+	When the working tree is updated, using --recurse-submodules will
+	also recursively reset the working tree of all active submodules
+	according to the commit recorded in the superproject, also setting
+	the submodules' HEAD to be detached at that commit.
 --
 
 See "Reset, restore and revert" in linkgit:git[1] for the differences
Documentation/git-restore.txt +11 -0
index 5bf60d4943..8e3b339802 100644
@@ -107,6 +107,17 @@ in linkgit:git-checkout[1] for details.
 	patterns and unconditionally restores any files in
 	`<pathspec>`.
 
+--recurse-submodules::
+--no-recurse-submodules::
+	If `<pathspec>` names an active submodule and the restore location
+	includes the working tree, the submodule will only be updated if
+	this option is given, in which case its working tree will be
+	restored to the commit recorded in the superproject, and any local
+	modifications overwritten. If nothing (or
+	`--no-recurse-submodules`) is used, submodules working trees will
+	not be updated. Just like linkgit:git-checkout[1], this will detach
+	`HEAD` of the submodule.
+
 --overlay::
 --no-overlay::
 	In overlay mode, the command never removes files when
Documentation/git-switch.txt +1 -1
index 197900363b..79dbc9624d 100644
@@ -183,7 +183,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 	Using `--recurse-submodules` will update the content of all
 	initialized submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
-	used, the work trees of submodules will not be updated. Just
+	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
 	submodules.
 
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#65 lore raw

PATCH v6 3/5 doc: explain how to deactivate submodule.recurse completely

In reply to Damien Robert
---
 Documentation/config/submodule.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/config/submodule.txt +7 -0
index 5962f41ead..d7a63c8c12 100644
@@ -63,6 +63,13 @@ submodule.recurse::
 	(`checkout`, `fetch`, `grep`, `pull`, `push`, `read-tree`, `reset`,
 	`restore` and `switch`) except `clone` and `ls-files`.
 	Defaults to false.
+	When set to true, it can be deactivated via the
+	`--no-recurse-submodules` option. Note that some Git commands
+	lacking this option may call some of the above commands affected by
+	`submodule.recurse`; for instance `git remote update` will call
+	`git fetch` but does not have a `--no-recurse-submodules` option.
+	For these commands a workaround is to temporarily change the
+	configuration value by using `git -c submodule.recurse=0`.
 
 submodule.fetchJobs::
 	Specifies how many submodules are fetched/cloned at the same time.
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#66 lore raw

PATCH v6 4/5 doc: be more precise on (fetch|push).recurseSubmodules

In reply to Damien Robert

The default value also depends on the value of submodule.recurse. Use this opportunity to correct some grammar mistakes in Documentation/config/fetch.txt signaled by Robert P. J. Day.

Also mention fetch.recurseSubmodules in fetch-options.txt. In git-push.txt, push.recurseSubmodules is implicitly mentioned (by explaining how to disable it), so no need to add it there.

Lastly add a link to git-fetch in git-pull.txt to explain the meaning of --recurse-submodules there.

---
 Documentation/config/fetch.txt  | 13 ++++++++-----
 Documentation/config/push.txt   |  2 ++
 Documentation/fetch-options.txt |  3 ++-
 Documentation/git-pull.txt      |  3 +--
 4 files changed, 13 insertions(+), 8 deletions(-)
Documentation/config/fetch.txt +8 -5
index f11940280f..b1a9b1461d 100644
@@ -1,11 +1,14 @@
 fetch.recurseSubmodules::
-	This option can be either set to a boolean value or to 'on-demand'.
+	This option controls whether `git fetch` (and the underlying fetch
+	in `git pull`) will recursively fetch into populated submodules.
+	This option can be set either to a boolean value or to 'on-demand'.
 	Setting it to a boolean changes the behavior of fetch and pull to
-	unconditionally recurse into submodules when set to true or to not
-	recurse at all when set to false. When set to 'on-demand' (the default
-	value), fetch and pull will only recurse into a populated submodule
-	when its superproject retrieves a commit that updates the submodule's
+	recurse unconditionally into submodules when set to true or to not
+	recurse at all when set to false. When set to 'on-demand', fetch and
+	pull will only recurse into a populated submodule when its
+	superproject retrieves a commit that updates the submodule's
 	reference.
+	Defaults to 'on-demand', or to the value of 'submodule.recurse' if set.
 
 fetch.fsckObjects::
 	If it is set to true, git-fetch-pack will check all fetched
Documentation/config/push.txt +2 -0
index 0a7aa322a9..f5e5b38c68 100644
@@ -112,3 +112,5 @@ push.recurseSubmodules::
 	is 'no' then default behavior of ignoring submodules when pushing
 	is retained. You may override this configuration at time of push by
 	specifying '--recurse-submodules=check|on-demand|no'.
+	If not set, 'no' is used by default, unless 'submodule.recurse' is
+	set (in which case a 'true' value means 'on-demand').
Documentation/fetch-options.txt +2 -1
index 00d03ec8c3..833f935cd0 100644
@@ -163,7 +163,8 @@ ifndef::git-pull[]
 	value. Use 'on-demand' to only recurse into a populated submodule
 	when the superproject retrieves a commit that updates the submodule's
 	reference to a commit that isn't already in the local submodule
-	clone.
+	clone. By default, 'on-demand' is used, unless
+	`fetch.recurseSubmodules` is set (see linkgit:git-config[1]).
 endif::git-pull[]
 
 -j::
Documentation/git-pull.txt +1 -2
index dfb901f8b8..47bc4a7061 100644
@@ -86,8 +86,7 @@ OPTIONS
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
 	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-config[1] and
-	linkgit:gitmodules[5]).
+	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
#67 lore raw

PATCH v6 5/5 doc: --recurse-submodules mostly applies to active submodules

In reply to Damien Robert

The documentation refers to "initialized" or "populated" submodules, to explain which submodules are affected by '--recurse-submodules', but the real terminology here is 'active' submodules. Update the documentation accordingly.

Some terminology:
- Active is defined in gitsubmodules(7), it only involves the configuration variables 'submodule.active', 'submodule.<name>.active' and 'submodule.<name>.url'. The function submodule.c::is_submodule_active checks that a submodule is active.
- Populated means that the submodule's working tree is present (and the gitfile correctly points to the submodule repository), i.e. either the superproject was cloned with --recurse-submodules, or the user ran git submodule update --init, or git submodule init [<path>] and git submodule update [<path>] separately which populated the submodule working tree. This does not involve the 3 configuration variables above.
- Initialized (at least in the context of the man pages involved in this patch) means both "populated" and "active" as defined above, i.e. what git submodule update --init does.

The --recurse-submodules option mostly affects active submodules. An exception is git fetch where the option affects populated submodules. As a consequence, in git pull --recurse-submodules the fetch affects populated submodules, but the resulting working tree update only affects active submodules.

In the documentation of git-pull, let's distinguish between the fetching part which affects populated submodules, and the updating of worktrees, which only affects active submodules.

---
 Documentation/git-checkout.txt  | 2 +-
 Documentation/git-grep.txt      | 2 +-
 Documentation/git-ls-files.txt  | 2 +-
 Documentation/git-pull.txt      | 6 ++++--
 Documentation/git-read-tree.txt | 2 +-
 Documentation/git-switch.txt    | 2 +-
 6 files changed, 9 insertions(+), 7 deletions(-)
Documentation/git-checkout.txt +1 -1
index 140bd3eabb..5b697eee1b 100644
@@ -292,7 +292,7 @@ Note that this option uses the no overlay mode by default (see also
 
 --recurse-submodules::
 --no-recurse-submodules::
-	Using `--recurse-submodules` will update the content of all initialized
+	Using `--recurse-submodules` will update the content of all active
 	submodules according to the commit recorded in the superproject. If
 	local modifications in a submodule would be overwritten the checkout
 	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
Documentation/git-grep.txt +1 -1
index ddb6acc025..cdf8e26b47 100644
@@ -93,7 +93,7 @@ OPTIONS
 	with `--no-index`.
 
 --recurse-submodules::
-	Recursively search in each submodule that has been initialized and
+	Recursively search in each submodule that is active and
 	checked out in the repository.  When used in combination with the
 	<tree> option the prefix of all submodule output will be the name of
 	the parent project's <tree> object. This option has no effect
Documentation/git-ls-files.txt +1 -1
index 8461c0e83e..3cb2ebb438 100644
@@ -148,7 +148,7 @@ a space) at the start of each line:
 	top directory.
 
 --recurse-submodules::
-	Recursively calls ls-files on each submodule in the repository.
+	Recursively calls ls-files on each active submodule in the repository.
 	Currently there is only support for the --cached mode.
 
 --abbrev[=<n>]::
Documentation/git-pull.txt +4 -2
index 47bc4a7061..b336df00c7 100644
@@ -85,8 +85,10 @@ OPTIONS
 	Pass --verbose to git-fetch and git-merge.
 
 --[no-]recurse-submodules[=yes|on-demand|no]::
-	This option controls if new commits of all populated submodules should
-	be fetched and updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and linkgit:gitmodules[5]).
+	This option controls if new commits of populated submodules should
+	be fetched, and if the working trees of active submodules should be
+	updated, too (see linkgit:git-fetch[1], linkgit:git-config[1] and
+	linkgit:gitmodules[5]).
 +
 If the checkout is done via rebase, local submodule commits are rebased as well.
 +
Documentation/git-read-tree.txt +1 -1
index 501f2ec375..5fa8bab64c 100644
@@ -116,7 +116,7 @@ OPTIONS
 	located in.
 
 --[no-]recurse-submodules::
-	Using --recurse-submodules will update the content of all initialized
+	Using --recurse-submodules will update the content of all active
 	submodules according to the commit recorded in the superproject by
 	calling read-tree recursively, also setting the submodules' HEAD to be
 	detached at that commit.
Documentation/git-switch.txt +1 -1
index 79dbc9624d..3759c3a265 100644
@@ -181,7 +181,7 @@ name, the guessing is aborted.  You can explicitly give a name with
 --recurse-submodules::
 --no-recurse-submodules::
 	Using `--recurse-submodules` will update the content of all
-	initialized submodules according to the commit recorded in the
+	active submodules according to the commit recorded in the
 	superproject. If nothing (or `--no-recurse-submodules`) is
 	used, submodules working trees will not be updated. Just
 	like linkgit:git-submodule[1], this will detach `HEAD` of the
Signature · 1 line
Patched on top of v2.26.0-106-g9fadedd637 (git version 2.26.0)
Reviewed-by on the v6 series
#68 lore raw
In reply to Damien Robert

Hi Damien,

Quoted 10 lines · Damien Robert

Fix typo mentioned by Junio.

Damien Robert (5):
doc: list all commands affected by submodule.recurse
doc: document --recurse-submodules for reset and restore
doc: explain how to deactivate submodule.recurse completely
doc: be more precise on (fetch|push).recurseSubmodules
doc: --recurse-submodules mostly applies to active submodules

A little late to the game, but consider this series

(It's my first review, so I don't know if I should explicitly add that to each patch?...)

Anyway, thanks a lot for putting time into this!

Philippe.