git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* submodule: --recurse-submodules vs. submodule.recurse=true
@ 2017-09-01  5:39 Magnus Homann
  2017-09-01  7:29 ` [PATCH] pull: honor submodule.recurse config option Nicolas Morey-Chaisemartin
  0 siblings, 1 reply; 5+ messages in thread
From: Magnus Homann @ 2017-09-01  5:39 UTC (permalink / raw)
  To: git

I'm using git 2.14.1 on cygwin.

Using --recurse-submodules, I can do 'git pull' and the submodules both get fetched and merged
automatically. I was under the impression that setting submodule.recurse to true would have the same
affect, without needing to write --recurse-submodules every time. But the docs seems a bit vague,
and I don't understand the git code.

Is there a way to config git pull to automatcially do a "--recurse-submodules" ?

Thanks,
Magnus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] pull: honor submodule.recurse config option
  2017-09-01  5:39 submodule: --recurse-submodules vs. submodule.recurse=true Magnus Homann
@ 2017-09-01  7:29 ` Nicolas Morey-Chaisemartin
  2017-09-01 17:11   ` Stefan Beller
  2017-09-01 17:28   ` Jonathan Nieder
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Morey-Chaisemartin @ 2017-09-01  7:29 UTC (permalink / raw)
  To: git; +Cc: magnus

git pull used to not parse the submodule.recurse config option and simply
consider the --recurse-submodules CLI option.
When using the config option, submodules would only be fetched recursively
while the CLi option would tigger both fetch and update/merge.

Reported-by: Magnus Homann <magnus@homann.se>
Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
---
 builtin/pull.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/builtin/pull.c b/builtin/pull.c
index 7fe281414..e4edf23c5 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -326,6 +326,11 @@ static int git_pull_config(const char *var, const char *value, void *cb)
 		config_autostash = git_config_bool(var, value);
 		return 0;
 	}
+	if (!strcmp(var, "submodule.recurse")) {
+		int r = git_config_bool(var, value) ?
+			RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
+		recurse_submodules = r;
+	}
 	return git_default_config(var, value, cb);
 }
 
-- 
2.14.1.460.g196d2604f


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pull: honor submodule.recurse config option
  2017-09-01  7:29 ` [PATCH] pull: honor submodule.recurse config option Nicolas Morey-Chaisemartin
@ 2017-09-01 17:11   ` Stefan Beller
  2017-09-01 18:15     ` René Scharfe
  2017-09-01 17:28   ` Jonathan Nieder
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Beller @ 2017-09-01 17:11 UTC (permalink / raw)
  To: Nicolas Morey-Chaisemartin; +Cc: git@vger.kernel.org, magnus

On Fri, Sep 1, 2017 at 12:29 AM, Nicolas Morey-Chaisemartin
<nicolas@morey-chaisemartin.com> wrote:
> git pull used to not parse the submodule.recurse config option and simply
> consider the --recurse-submodules CLI option.
> When using the config option, submodules would only be fetched recursively
> while the CLi option would tigger both fetch and update/merge.
>
> Reported-by: Magnus Homann <magnus@homann.se>
> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>

Reviewed-by: Stefan Beller <sbeller@google.com>

Thanks,
Stefan


> ---
>  builtin/pull.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/builtin/pull.c b/builtin/pull.c
> index 7fe281414..e4edf23c5 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -326,6 +326,11 @@ static int git_pull_config(const char *var, const char *value, void *cb)
>                 config_autostash = git_config_bool(var, value);
>                 return 0;
>         }
> +       if (!strcmp(var, "submodule.recurse")) {
> +               int r = git_config_bool(var, value) ?
> +                       RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
> +               recurse_submodules = r;
> +       }
>         return git_default_config(var, value, cb);
>  }
>
> --
> 2.14.1.460.g196d2604f
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pull: honor submodule.recurse config option
  2017-09-01  7:29 ` [PATCH] pull: honor submodule.recurse config option Nicolas Morey-Chaisemartin
  2017-09-01 17:11   ` Stefan Beller
@ 2017-09-01 17:28   ` Jonathan Nieder
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Nieder @ 2017-09-01 17:28 UTC (permalink / raw)
  To: Nicolas Morey-Chaisemartin; +Cc: git, magnus

Hi,

Nicolas Morey-Chaisemartin wrote:

> git pull used to not parse the submodule.recurse config option and simply
> consider the --recurse-submodules CLI option.
> When using the config option, submodules would only be fetched recursively
> while the CLi option would tigger both fetch and update/merge.
>
> Reported-by: Magnus Homann <magnus@homann.se>
> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>

nits:

* Git's commit messages usually use the present tense to describe the
  behavior of Git in absence of a patch, as though writing a bug report.
  They use the imperative mood to describe what the patch will do, as
  though commanding the code to do better.
* spelling: s/CLi/CLI/; s/tigger/trigger/
* please also wrap lines consistently

That would make

	"git pull" supports a --recurse-submodules option but does not parse the
	submodule.recurse configuration item to set the default for that option.
	Meanwhile "git fetch" does support submodule.recurse, producing
	confusing behavior: when submodule.recurse is enabled, "git pull"
	recursively fetches submodules but does not update them after fetch.

	Handle submodule.recurse in "git pull" to fix this.

> ---
>  builtin/pull.c | 5 +++++
>  1 file changed, 5 insertions(+)

Can you add a test to avoid future changes causing this to regress?
See t/t5572-pull-submodule.sh for some existing tests to get
inspiration from.

> diff --git a/builtin/pull.c b/builtin/pull.c
> index 7fe281414..e4edf23c5 100644
> --- a/builtin/pull.c
> +++ b/builtin/pull.c
> @@ -326,6 +326,11 @@ static int git_pull_config(const char *var, const char *value, void *cb)
>  		config_autostash = git_config_bool(var, value);
>  		return 0;
>  	}
> +	if (!strcmp(var, "submodule.recurse")) {
> +		int r = git_config_bool(var, value) ?
> +			RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;
> +		recurse_submodules = r;
> +	}
>  	return git_default_config(var, value, cb);
>  }
>  

The rest looks good.

Thanks for working on this,
Jonathan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pull: honor submodule.recurse config option
  2017-09-01 17:11   ` Stefan Beller
@ 2017-09-01 18:15     ` René Scharfe
  0 siblings, 0 replies; 5+ messages in thread
From: René Scharfe @ 2017-09-01 18:15 UTC (permalink / raw)
  To: Stefan Beller, Nicolas Morey-Chaisemartin; +Cc: git@vger.kernel.org, magnus

Am 01.09.2017 um 19:11 schrieb Stefan Beller:
> On Fri, Sep 1, 2017 at 12:29 AM, Nicolas Morey-Chaisemartin
> <nicolas@morey-chaisemartin.com> wrote:
>> git pull used to not parse the submodule.recurse config option and simply
>> consider the --recurse-submodules CLI option.
>> When using the config option, submodules would only be fetched recursively
>> while the CLi option would tigger both fetch and update/merge.
>>
>> Reported-by: Magnus Homann <magnus@homann.se>
>> Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
> 
> Reviewed-by: Stefan Beller <sbeller@google.com>
> 
> Thanks,
> Stefan
> 
> 
>> ---
>>   builtin/pull.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/builtin/pull.c b/builtin/pull.c
>> index 7fe281414..e4edf23c5 100644
>> --- a/builtin/pull.c
>> +++ b/builtin/pull.c
>> @@ -326,6 +326,11 @@ static int git_pull_config(const char *var, const char *value, void *cb)
>>                  config_autostash = git_config_bool(var, value);
>>                  return 0;
>>          }
>> +       if (!strcmp(var, "submodule.recurse")) {
>> +               int r = git_config_bool(var, value) ?
>> +                       RECURSE_SUBMODULES_ON : RECURSE_SUBMODULES_OFF;>> +               recurse_submodules = r;

A few nits to pick:

Why not assign directly to recurse_submodules?  The variable r is only
set once and read once, and doesn't have a particularly descriptive name
that would justify having it.

builtin/fetch.c::git_fetch_config(), builtin/push.c::git_push_config()
and submodule.c::git_default_submodule_config() do the same, and I can't
infer why for them either.

And why fall through to git_default_config() here even though we know
that it won't match "submodule.recurse" again?  Config functions are
usually exit early on finding a match, as the "rebase.autostash" handler
above does.

>> +       }
>>          return git_default_config(var, value, cb);
>>   }
>>
>> --
>> 2.14.1.460.g196d2604f
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-01 18:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01  5:39 submodule: --recurse-submodules vs. submodule.recurse=true Magnus Homann
2017-09-01  7:29 ` [PATCH] pull: honor submodule.recurse config option Nicolas Morey-Chaisemartin
2017-09-01 17:11   ` Stefan Beller
2017-09-01 18:15     ` René Scharfe
2017-09-01 17:28   ` Jonathan Nieder

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