From: Junio C Hamano <gitster@pobox.com>
To: Markus Klein <masmiseim@gmx.de>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org,
"Markus Klein via GitGitGadget" <gitgitgadget@gmail.com>
Subject: Re: [PATCH v2] clone: use submodules.recurse option for automatically clone submodules
Date: Fri, 07 Feb 2020 10:33:56 -0800 [thread overview]
Message-ID: <xmqqa75u457v.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <xmqq1rr7fsh3.fsf@gitster-ct.c.googlers.com> (Junio C. Hamano's message of "Thu, 06 Feb 2020 11:03:52 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> So, I would sort-of understand if you pretend --recurse-submodules
> was given from the command line when submodule.recurse is set to
> true (which would mean that you'd append "." to the string list).
> But I do not understand why appending "true" is a good thing at all
> here.
>
> Another thing I noticed.
>
> If you have "[submodule] recurse" in your $HOME/.gitconfig, you'd
> want to be able to countermand from the command line with
>
> git clone --no-recurse-submodules ...
>
> so that the clone would not go recursive. And that should be
> tested.
>
> You'd also want the opposite, i.e. with "[submodule] recurse=no" in
> your $HOME/.gitconfig and running
>
> git clone --recurse-submodules ...
>
> should countermand the configuration.
Totally untested, but just to illustrate the approach, here is a
sample patch to implement "Pretend --recurse-submodules=. is set on
the command line when submodule.recurse is set (in the 'last one
wins' sense) and there is no --recurse-submodules command line
option." It should outline the right interactions between the
command line options and configuration variable, like allowing "git
clone --no-recurse-submodules" to defeat submodule.recurse
configuration.
Not that I agree that "[submodules] recurse" set in the
$HOME/.gitconfig should affect "git clone". It is merely to
illustrate how it could be done, if it were a good idea.
builtin/clone.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 0fc89ae2b9..163803d89e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -32,6 +32,7 @@
#include "connected.h"
#include "packfile.h"
#include "list-objects-filter-options.h"
+#include "submodule.h"
/*
* Overall FIXMEs:
@@ -71,6 +72,8 @@ static struct list_objects_filter_options filter_options;
static struct string_list server_options = STRING_LIST_INIT_NODUP;
static int option_remote_submodules;
+static int recurse_submodules_option_given;
+
static int recurse_submodules_cb(const struct option *opt,
const char *arg, int unset)
{
@@ -81,7 +84,7 @@ static int recurse_submodules_cb(const struct option *opt,
else
string_list_append((struct string_list *)opt->value,
(const char *)opt->defval);
-
+ recurse_submodules_option_given = 1;
return 0;
}
@@ -929,6 +932,13 @@ static int path_exists(const char *path)
return !stat(path, &sb);
}
+static int git_clone_config(const char *var, const char *value, void *cb)
+{
+ if (starts_with(var, "submodule."))
+ return git_default_submodule_config(var, value, NULL);
+ return git_default_config(var, value, cb);
+}
+
int cmd_clone(int argc, const char **argv, const char *prefix)
{
int is_bundle = 0, is_local;
@@ -1103,7 +1113,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
write_config(&option_config);
- git_config(git_default_config, NULL);
+ git_config(git_clone_config, NULL);
+ if (!recurse_submodules_option_given && should_update_submodules())
+ string_list_append(&option_recurse_submodules, ".");
if (option_bare) {
if (option_mirror)
next prev parent reply other threads:[~2020-02-07 18:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-31 21:11 [PATCH] clone: use submodules.recurse option for automatically clone submodules Markus Klein via GitGitGadget
2020-02-01 21:19 ` Johannes Schindelin
2020-02-04 21:32 ` [PATCH v2] " Markus Klein via GitGitGadget
2020-02-05 10:37 ` Johannes Schindelin
2020-02-06 19:03 ` Junio C Hamano
2020-02-07 15:45 ` Johannes Schindelin
2020-02-07 18:17 ` Junio C Hamano
2020-02-07 18:33 ` Junio C Hamano [this message]
2020-02-24 22:19 ` AW: " masmiseim
2020-02-24 23:06 ` [PATCH v3] clone: use submodule.recurse " Markus Klein via GitGitGadget
2020-05-01 13:54 ` [PATCH v4] " Markus Klein via GitGitGadget
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=xmqqa75u457v.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=masmiseim@gmx.de \
/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).