diff mbox series

doc: mention that 'git submodule update' fetches missing commits

Message ID 0102016b72a55a7d-fb4ecdb7-9f2b-4204-b888-0000f209c3ff-000000@eu-west-1.amazonses.com (mailing list archive)
State New, archived
Headers show
Series doc: mention that 'git submodule update' fetches missing commits | expand

Commit Message

Philippe Blain June 20, 2019, 2:09 a.m. UTC
'git submodule update' will fetch new commits from the submodule remote
if the SHA-1 recorded in the superproject is not found. This was not
mentioned in the documentation.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 Documentation/git-submodule.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


--
https://github.com/git/git/pull/596

Comments

Junio C Hamano June 20, 2019, 6:09 p.m. UTC | #1
Philippe Blain <levraiphilippeblain@gmail.com> writes:

> 'git submodule update' will fetch new commits from the submodule remote
> if the SHA-1 recorded in the superproject is not found. This was not
> mentioned in the documentation.
>
> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
> ---
>  Documentation/git-submodule.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index 2794e2978021c..930bfcee50e4c 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -132,7 +132,8 @@ update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--forc
>  +
>  --
>  Update the registered submodules to match what the superproject
> -expects by cloning missing submodules and updating the working tree of
> +expects by cloning missing submodules, fetching missing submodule commits
> +and updating the working tree of
>  the submodules. The "updating" can be done in several ways depending
>  on command line options and the value of `submodule.<name>.update`
>  configuration variable. The command line option takes precedence over

The additional text may not be wrong per-se, but isn't it fairly
obvious that there is no other way than to fetch, in order to
"update the registered submodules to match what the superproject
expects", aka "if the commit object name recorded in the
superproject is not found".  How else would the subcommand come up
with the missing commit out of thin air?

IOW, I have to wonder if this is worth saying, or if these new words
are just adding more things the readers need to scan on the page
without adding that much information.
Philippe Blain Nov. 19, 2019, 3:55 a.m. UTC | #2
Hi Junio,

First off, sorry for not answering this summer. 
Dscho suggested [1] I try to convince you. 

> Le 20 juin 2019 à 14:09, Junio C Hamano <gitster@pobox.com> a écrit :
> 
> The additional text may not be wrong per-se, but isn't it fairly
> obvious that there is no other way than to fetch, in order to
> "update the registered submodules to match what the superproject
> expects »,

Well, that’s true, but I think that it is important in the documentation to be thorough as to what git commands talk to a remote in what circumstances, and which don’t (this is something that is sometimes not obvious to new users in my opinion). Since by default ‘git pull’ will fetch missing submodule commits, it may not be obvious that ‘git submodule update’ will also fetch from a remote if need be. 

> How else would the subcommand come up
> with the missing commit out of thin air?

Since 'git pull’ will fetch submodules changes, and is usually run first, the commits are usually already there, but I think it’s worth mentioning that they will be fetched if they need to.

I like thoroughness in software documentation :) 

Philippe.

[1] https://github.com/git/git/pull/596
Junio C Hamano Nov. 20, 2019, 2:51 a.m. UTC | #3
Philippe Blain <levraiphilippeblain@gmail.com> writes:

> Since 'git pull’ will fetch submodules changes, and is usually
> run first, the commits are usually already there, but I think
> it’s worth mentioning that they will be fetched if they need to.
>
> I like thoroughness in software documentation :) 

Where to draw the line between being thorough and being overly
verbose with trivial things is subjective, so I generally tend to
side with status quo.  But after re-reading the updated text, I do
not think it is so bad, so let's apply it with a bit of tweak.

The lines prefixed with "++" are with my tweak, "- " are your
original changes and " -" are what was in the version before your
patch (I CC'ed Pratyush to show this as an example of what I meant
by using combined diff to express an amended commit):

$ git diff -c HEAD HEAD@{1} HEAD^
diff --combined Documentation/git-submodule.txt
index 16c765cbfa,0ed5c24dc1..4beb569ae5
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@@ -133,8 -133,7 +133,8 @@@ update [--init] [--remote] [-N|--no-fet
  +
  --
  Update the registered submodules to match what the superproject
- expects by cloning missing submodules, fetching missing submodule commits
- and updating the working tree of
 -expects by cloning missing submodules and updating the working tree of
++expects by cloning missing submodules, fetching missing commits
++in submodules and updating the working tree of
  the submodules. The "updating" can be done in several ways depending
  on command line options and the value of `submodule.<name>.update`
  configuration variable. The command line option takes precedence over
diff mbox series

Patch

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 2794e2978021c..930bfcee50e4c 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -132,7 +132,8 @@  update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--forc
 +
 --
 Update the registered submodules to match what the superproject
-expects by cloning missing submodules and updating the working tree of
+expects by cloning missing submodules, fetching missing submodule commits
+and updating the working tree of
 the submodules. The "updating" can be done in several ways depending
 on command line options and the value of `submodule.<name>.update`
 configuration variable. The command line option takes precedence over