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

Re: [PATCH v2] clone: use submodules.recurse option for automatically clone submodules

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 7, 2020, 15:45 UTC
Message-ID
<nycvar.QRO.7.76.6.2002071621160.3718@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqq1rr7fsh3.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Thu, 6 Feb 2020, Junio C Hamano wrote:
Show 21 quoted lines
> "Markus Klein via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > +static int git_clone_config(const char *var, const char *value, void *cb)
> > +{
> > +	if (!strcmp(var, "submodule.recurse") && git_config_bool(var, value)) {
> > +		string_list_append(&option_recurse_submodules, "true");
> > +		return 0;
>
> The breakage of this is not apparent, but this is misleading.  If
> submodule.recurse is set to a value that git_config_bool() would say
> "false", the if statement is skipped, and you end up calling
> git_default_config() with "submodule.recurse", even though you are
> supposed to have already dealt with the setting.
>
> 	if (!strcmp(var, "submodule.recurse")) {
> 		if (git_config_bool(var, value))
> 			...
> 		return 0; /* done with the variable either way */
> 	}
>
> is more appropriate.

Good catch, and I think you will have to do even more: in the "else" case, it is possible that the user overrode a `submodule.recurse` from the system config in their user-wide config, so we must _undo_ the `string_list_append().

Further, it is probably not a good idea to append "true" _twice_ if multiple configs in the chain specify `submodule.recurse = true`.

Show 24 quoted lines
> I still do not know what this code is trying to do by appending "true"
> as many times as submodule.recurse appears in the configuration file(s),
> though.
>
> When given from the command line, i.e.
>
> 	git clone --no-recurse-submodules ...
> 	git clone --recurse-submodules    ...
> 	git clone --recurse-submodules=<something> ...
>
> recurse_submodules_cb() reacts to them by
>
>  (1) clearing what have been accumulated so far,
>  (2) appending the match-all "." pathspec, and
>  (3) appending the <something> string
>
> to option_recurse_submodules string list.  But given that
> submodule.recurse is not (and will not be without an involved
> transition plan) a pathspec but merely a boolean, I would think
> appending hardcoded string constant "true" makes little sense.
> After sorting the list, these values become values of the
> submodule.active configuration variable whose values are pathspec
> elements in cmd_clone(); see the part of the code before it makes a
> call to init_db().

Indeed, I think I even pointed out that "true" is not an appropriate value to use here: https://github.com/git/git/pull/695/#discussion_r367866708

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 11 in “clone: use submodules.recurse option for automatically clone submodules”
  1. clone: use submodules.recurse option for automatically clone submodulesMarkus Klein via GitGitGadget, Jan 31, 2020
  2. Johannes SchindelinFeb 1, 2020
  3. clone: use submodules.recurse option for automatically clone submodulesMarkus Klein via GitGitGadget, Feb 4, 2020
  4. Johannes SchindelinFeb 5, 2020
  5. Junio C HamanoFeb 6, 2020
  6. Johannes SchindelinFeb 7, 2020
  7. Junio C HamanoFeb 7, 2020
  8. Junio C HamanoFeb 7, 2020
  9. AW: [PATCH v2] clone: use submodules.recurse option for automatically clone submodulesmasmiseim@gmx.de, Feb 24, 2020
  10. clone: use submodule.recurse option for automatically clone submodulesMarkus Klein via GitGitGadget, Feb 24, 2020
  11. clone: use submodule.recurse option for automatically clone submodulesMarkus Klein via GitGitGadget, May 1, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.