Skip to content

Commit 60736db

Browse files
committed
Merge branch 'ks/submodule-doc-updates' into maint
Doc updates. * ks/submodule-doc-updates: Doc/git-submodule: improve readability and grammar of a sentence Doc/gitsubmodules: make some changes to improve readability and syntax
2 parents b1bdf46 + e1b3f3d commit 60736db

File tree

2 files changed

+87
-29
lines changed

2 files changed

+87
-29
lines changed

Documentation/git-submodule.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ status [--cached] [--recursive] [--] [<path>...]::
7070
Show the status of the submodules. This will print the SHA-1 of the
7171
currently checked out commit for each submodule, along with the
7272
submodule path and the output of 'git describe' for the
73-
SHA-1. Each SHA-1 will be prefixed with `-` if the submodule is not
74-
initialized, `+` if the currently checked out submodule commit
73+
SHA-1. Each SHA-1 will possibly be prefixed with `-` if the submodule is
74+
not initialized, `+` if the currently checked out submodule commit
7575
does not match the SHA-1 found in the index of the containing
7676
repository and `U` if the submodule has merge conflicts.
7777
+
@@ -132,15 +132,15 @@ expects by cloning missing submodules and updating the working tree of
132132
the submodules. The "updating" can be done in several ways depending
133133
on command line options and the value of `submodule.<name>.update`
134134
configuration variable. The command line option takes precedence over
135-
the configuration variable. if neither is given, a checkout is performed.
136-
update procedures supported both from the command line as well as setting
137-
`submodule.<name>.update`:
135+
the configuration variable. If neither is given, a 'checkout' is performed.
136+
The 'update' procedures supported both from the command line as well as
137+
through the `submodule.<name>.update` configuration are:
138138

139139
checkout;; the commit recorded in the superproject will be
140140
checked out in the submodule on a detached HEAD.
141141
+
142142
If `--force` is specified, the submodule will be checked out (using
143-
`git checkout --force` if appropriate), even if the commit specified
143+
`git checkout --force`), even if the commit specified
144144
in the index of the containing repository already matches the commit
145145
checked out in the submodule.
146146

@@ -150,8 +150,8 @@ checked out in the submodule.
150150
merge;; the commit recorded in the superproject will be merged
151151
into the current branch in the submodule.
152152

153-
The following procedures are only available via the `submodule.<name>.update`
154-
configuration variable:
153+
The following 'update' procedures are only available via the
154+
`submodule.<name>.update` configuration variable:
155155

156156
custom command;; arbitrary shell command that takes a single
157157
argument (the sha1 of the commit recorded in the

Documentation/gitsubmodules.txt

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ The `gitlink` entry contains the object name of the commit that the
3636
superproject expects the submodule’s working directory to be at.
3737

3838
The section `submodule.foo.*` in the `.gitmodules` file gives additional
39-
hints to Gits porcelain layer such as where to obtain the submodule via
40-
the `submodule.foo.url` setting.
39+
hints to Git's porcelain layer. For example, the `submodule.foo.url`
40+
setting specifies where to obtain the submodule.
4141

4242
Submodules can be used for at least two different use cases:
4343

@@ -51,18 +51,21 @@ Submodules can be used for at least two different use cases:
5151

5252
2. Splitting a (logically single) project into multiple
5353
repositories and tying them back together. This can be used to
54-
overcome current limitations of Gits implementation to have
54+
overcome current limitations of Git's implementation to have
5555
finer grained access:
5656

57-
* Size of the git repository:
57+
* Size of the Git repository:
5858
In its current form Git scales up poorly for large repositories containing
5959
content that is not compressed by delta computation between trees.
60-
However you can also use submodules to e.g. hold large binary assets
61-
and these repositories are then shallowly cloned such that you do not
60+
For example, you can use submodules to hold large binary assets
61+
and these repositories can be shallowly cloned such that you do not
6262
have a large history locally.
6363
* Transfer size:
6464
In its current form Git requires the whole working tree present. It
6565
does not allow partial trees to be transferred in fetch or clone.
66+
If the project you work on consists of multiple repositories tied
67+
together as submodules in a superproject, you can avoid fetching the
68+
working trees of the repositories you are not interested in.
6669
* Access control:
6770
By restricting user access to submodules, this can be used to implement
6871
read/write policies for different users.
@@ -73,9 +76,10 @@ The configuration of submodules
7376
Submodule operations can be configured using the following mechanisms
7477
(from highest to lowest precedence):
7578

76-
* The command line for those commands that support taking submodule specs.
77-
Most commands have a boolean flag '--recurse-submodules' whether to
78-
recurse into submodules. Examples are `ls-files` or `checkout`.
79+
* The command line for those commands that support taking submodules
80+
as part of their pathspecs. Most commands have a boolean flag
81+
`--recurse-submodules` which specify whether to recurse into submodules.
82+
Examples are `grep` and `checkout`.
7983
Some commands take enums, such as `fetch` and `push`, where you can
8084
specify how submodules are affected.
8185

@@ -87,8 +91,8 @@ Submodule operations can be configured using the following mechanisms
8791
For example an effect from the submodule's `.gitignore` file
8892
would be observed when you run `git status --ignore-submodules=none` in
8993
the superproject. This collects information from the submodule's working
90-
directory by running `status` in the submodule, which does pay attention
91-
to its `.gitignore` file.
94+
directory by running `status` in the submodule while paying attention
95+
to the `.gitignore` file of the submodule.
9296
+
9397
The submodule's `$GIT_DIR/config` file would come into play when running
9498
`git push --recurse-submodules=check` in the superproject, as this would
@@ -97,20 +101,20 @@ remotes are configured in the submodule as usual in the `$GIT_DIR/config`
97101
file.
98102

99103
* The configuration file `$GIT_DIR/config` in the superproject.
100-
Typical configuration at this place is controlling if a submodule
101-
is recursed into at all via the `active` flag for example.
104+
Git only recurses into active submodules (see "ACTIVE SUBMODULES"
105+
section below).
102106
+
103107
If the submodule is not yet initialized, then the configuration
104-
inside the submodule does not exist yet, so configuration where to
108+
inside the submodule does not exist yet, so where to
105109
obtain the submodule from is configured here for example.
106110

107-
* the `.gitmodules` file inside the superproject. Additionally to the
108-
required mapping between submodule's name and path, a project usually
111+
* The `.gitmodules` file inside the superproject. A project usually
109112
uses this file to suggest defaults for the upstream collection
110-
of repositories.
113+
of repositories for the mapping that is required between a
114+
submodule's name and its path.
111115
+
112-
This file mainly serves as the mapping between name and path in
113-
the superproject, such that the submodule's git directory can be
116+
This file mainly serves as the mapping between the name and path of submodules
117+
in the superproject, such that the submodule's Git directory can be
114118
located.
115119
+
116120
If the submodule has never been initialized, this is the only place
@@ -137,8 +141,8 @@ directory is automatically moved to `$GIT_DIR/modules/<name>/`
137141
of the superproject.
138142

139143
* Deinitialized submodule: A `gitlink`, and a `.gitmodules` entry,
140-
but no submodule working directory. The submodule’s git directory
141-
may be there as after deinitializing the git directory is kept around.
144+
but no submodule working directory. The submodule’s Git directory
145+
may be there as after deinitializing the Git directory is kept around.
142146
The directory which is supposed to be the working directory is empty instead.
143147
+
144148
A submodule can be deinitialized by running `git submodule deinit`.
@@ -160,6 +164,60 @@ from another repository.
160164
To completely remove a submodule, manually delete
161165
`$GIT_DIR/modules/<name>/`.
162166

167+
ACTIVE SUBMODULES
168+
-----------------
169+
170+
A submodule is considered active,
171+
172+
(a) if `submodule.<name>.active` is set to `true`
173+
or
174+
(b) if the submodule's path matches the pathspec in `submodule.active`
175+
or
176+
(c) if `submodule.<name>.url` is set.
177+
178+
and these are evaluated in this order.
179+
180+
For example:
181+
182+
[submodule "foo"]
183+
active = false
184+
url = https://example.org/foo
185+
[submodule "bar"]
186+
active = true
187+
url = https://example.org/bar
188+
[submodule "baz"]
189+
url = https://example.org/baz
190+
191+
In the above config only the submodule 'bar' and 'baz' are active,
192+
'bar' due to (a) and 'baz' due to (c). 'foo' is inactive because
193+
(a) takes precedence over (c)
194+
195+
Note that (c) is a historical artefact and will be ignored if the
196+
(a) and (b) specify that the submodule is not active. In other words,
197+
if we have an `submodule.<name>.active` set to `false` or if the
198+
submodule's path is excluded in the pathspec in `submodule.active`, the
199+
url doesn't matter whether it is present or not. This is illustrated in
200+
the example that follows.
201+
202+
[submodule "foo"]
203+
active = true
204+
url = https://example.org/foo
205+
[submodule "bar"]
206+
url = https://example.org/bar
207+
[submodule "baz"]
208+
url = https://example.org/baz
209+
[submodule "bob"]
210+
ignore = true
211+
[submodule]
212+
active = b*
213+
active = :(exclude) baz
214+
215+
In here all submodules except 'baz' (foo, bar, bob) are active.
216+
'foo' due to its own active flag and all the others due to the
217+
submodule active pathspec, which specifies that any submodule
218+
starting with 'b' except 'baz' are also active, regardless of the
219+
presence of the .url field.
220+
163221
Workflow for a third party library
164222
----------------------------------
165223

0 commit comments

Comments
 (0)