git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Damien Robert <damien.olivier.robert@gmail.com>
Cc: git@vger.kernel.org, Damien Robert <damien.olivier.robert+git@gmail.com>
Subject: Re: [PATCH 2/4] doc: document --recurse-submodules for reset and restore
Date: Sun, 1 Mar 2020 23:45:02 -0500	[thread overview]
Message-ID: <9831AAEE-8FBF-4CBD-B589-3F045720D6DC@gmail.com> (raw)
In-Reply-To: <20200228103558.1684937-3-damien.olivier.robert+git@gmail.com>


> Le 28 févr. 2020 à 05:35, Damien Robert <damien.olivier.robert@gmail.com> a écrit :
> 
> Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
> ---
> Documentation/git-reset.txt   | 6 ++++++
> Documentation/git-restore.txt | 9 +++++++++
> 2 files changed, 15 insertions(+)
> 
> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
> index 932080c55d..838c0f1101 100644
> --- a/Documentation/git-reset.txt
> +++ b/Documentation/git-reset.txt
> @@ -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.
> —

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...

> 
> See "Reset, restore and revert" in linkgit:git[1] for the differences
> diff --git a/Documentation/git-restore.txt b/Documentation/git-restore.txt
> index 5bf60d4943..b94b2559c7 100644
> --- a/Documentation/git-restore.txt
> +++ b/Documentation/git-restore.txt
> @@ -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.

> 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.
> +

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.

> --overlay::
> --no-overlay::
> 	In overlay mode, the command never removes files when
> -- 
> Patched on top of v2.25.1-377-g2d2118b814 (git version 2.25.1)
> 


  reply	other threads:[~2020-03-02  4:45 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28 10:35 [PATCH 0/4] doc: --recurse-submodules Damien Robert
2020-02-28 10:35 ` [PATCH 1/4] doc: list all commands affected by recurse.submodule Damien Robert
2020-03-02  4:43   ` Philippe Blain
2020-03-03 17:09     ` Damien Robert
2020-02-28 10:35 ` [PATCH 2/4] doc: document --recurse-submodules for reset and restore Damien Robert
2020-03-02  4:45   ` Philippe Blain [this message]
2020-03-03 17:26     ` Damien Robert
2020-03-06  4:16       ` Philippe Blain
2020-02-28 10:35 ` [PATCH 3/4] doc: explain how to deactivate recurse.submodule completely Damien Robert
2020-03-02  4:45   ` Philippe Blain
2020-02-28 10:35 ` [PATCH 4/4] doc: be more precise on (fetch|pull).recurseSubmodules Damien Robert
2020-03-02  4:46   ` Philippe Blain
2020-02-28 10:44 ` [PATCH 0/4] doc: --recurse-submodules Damien Robert
2020-03-03  5:18   ` Philippe Blain
2020-03-02  4:47 ` Philippe Blain
2020-03-03 17:07 ` [PATCH v2 0/5] " Damien Robert
2020-03-03 17:07   ` [PATCH v2 1/5] doc: list all commands affected by submodule.recurse Damien Robert
2020-03-03 17:07   ` [PATCH v2 2/5] doc: document --recurse-submodules for reset and restore Damien Robert
2020-03-03 21:54     ` Junio C Hamano
2020-03-06  4:16     ` Philippe Blain
2020-03-03 17:07   ` [PATCH v2 3/5] doc: explain how to deactivate recurse.submodule completely Damien Robert
2020-03-03 21:57     ` Junio C Hamano
2020-03-03 22:05       ` Robert P. J. Day
2020-03-03 22:04     ` Damien Robert
2020-03-06  4:16       ` Philippe Blain
2020-03-03 17:07   ` [PATCH v2 4/5] doc: be more precise on (fetch|push).recurseSubmodules Damien Robert
2020-03-03 22:05     ` Junio C Hamano
2020-03-03 22:12       ` Robert P. J. Day
2020-03-03 17:07   ` [PATCH v2 5/5] doc: --recurse-submodules only apply to active submodules Damien Robert
2020-03-06  4:17     ` Philippe Blain
2020-03-20 22:23       ` Damien Robert
2020-03-20 21:37 ` [PATCH v3 0/5] doc: --recurse-submodules Damien Robert
2020-03-20 21:37   ` [PATCH v3 1/5] doc: list all commands affected by submodule.recurse Damien Robert
2020-03-20 21:37   ` [PATCH v3 2/5] doc: document --recurse-submodules for reset and restore Damien Robert
2020-03-22 22:36     ` Philippe Blain
2020-03-25 21:05       ` Damien Robert
2020-03-20 21:37   ` [PATCH v3 3/5] doc: explain how to deactivate submodule.recurse completely Damien Robert
2020-03-22 22:36     ` Philippe Blain
2020-03-20 21:37   ` [PATCH v3 4/5] doc: be more precise on (fetch|push).recurseSubmodules Damien Robert
2020-03-22 22:37     ` Philippe Blain
2020-03-22 23:01       ` Junio C Hamano
2020-03-22 23:21         ` Philippe Blain
2020-03-20 21:37   ` [PATCH v3 5/5] doc: --recurse-submodules mostly only apply to active submodules Damien Robert
2020-03-22 22:38     ` Philippe Blain
2020-03-25 21:09   ` [PATCH v4 0/5] doc: --recurse-submodules Damien Robert
2020-03-25 21:09     ` [PATCH v4 1/5] doc: list all commands affected by submodule.recurse Damien Robert
2020-03-25 21:09     ` [PATCH v4 2/5] doc: document --recurse-submodules for reset and restore Damien Robert
2020-03-29 20:34       ` Philippe Blain
2020-03-25 21:09     ` [PATCH v4 3/5] doc: explain how to deactivate submodule.recurse completely Damien Robert
2020-03-25 21:09     ` [PATCH v4 4/5] doc: be more precise on (fetch|push).recurseSubmodules Damien Robert
2020-03-29 20:49       ` Philippe Blain
2020-03-25 21:09     ` [PATCH v4 5/5] doc: --recurse-submodules mostly applies to active submodules Damien Robert
2020-04-05 20:16   ` [PATCH v5 0/5] doc: --recurse-submodules Damien Robert
2020-04-05 20:16     ` [PATCH v5 1/5] doc: list all commands affected by submodule.recurse Damien Robert
2020-04-05 20:16     ` [PATCH v5 2/5] doc: document --recurse-submodules for reset and restore Damien Robert
2020-04-05 20:16     ` [PATCH v5 3/5] doc: explain how to deactivate submodule.recurse completely Damien Robert
2020-04-05 20:16     ` [PATCH v5 4/5] doc: be more precise on (fetch|push).recurseSubmodules Damien Robert
2020-04-05 21:57       ` Junio C Hamano
2020-04-06 13:49         ` Damien Robert
2020-04-06 17:56           ` Junio C Hamano
2020-04-06 18:42             ` Damien Robert
2020-04-05 20:16     ` [PATCH v5 5/5] doc: --recurse-submodules mostly applies to active submodules Damien Robert
2020-04-06 13:57   ` [PATCH v6 0/5] doc: --recurse-submodules Damien Robert
2020-04-06 13:57     ` [PATCH v6 1/5] doc: list all commands affected by submodule.recurse Damien Robert
2020-04-06 13:57     ` [PATCH v6 2/5] doc: document --recurse-submodules for reset and restore Damien Robert
2020-04-06 13:57     ` [PATCH v6 3/5] doc: explain how to deactivate submodule.recurse completely Damien Robert
2020-04-06 13:57     ` [PATCH v6 4/5] doc: be more precise on (fetch|push).recurseSubmodules Damien Robert
2020-04-06 13:57     ` [PATCH v6 5/5] doc: --recurse-submodules mostly applies to active submodules Damien Robert
2020-04-16 13:09     ` [PATCH v6 0/5] doc: --recurse-submodules Philippe Blain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9831AAEE-8FBF-4CBD-B589-3F045720D6DC@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=damien.olivier.robert+git@gmail.com \
    --cc=damien.olivier.robert@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).