git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: bmwill@google.com
Cc: git@vger.kernel.org, gitster@pobox.com,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH 4/8] submodule loading: separate code path for .gitmodules and config overlay
Date: Fri, 26 May 2017 12:10:13 -0700	[thread overview]
Message-ID: <20170526191017.19155-5-sbeller@google.com> (raw)
In-Reply-To: <20170526191017.19155-1-sbeller@google.com>

The .gitmodules file is not supposed to have all the options available,
that are available in the configuration so separate it out.

A configuration option such as the hypothetical submodule.color.diff
that determines in which color a submodule change is printed,
is a very user specific thing, that the .gitmodules file should
not tamper with.

The .gitmodules file should only be used for settings that required
to setup the project in which the .gitmodules file is tracked. As the
minimum this would only include the name<->path mapping of the
submodule and its URL and branch.

Any further setting (such as 'fetch.recursesubmodules' or
'submodule.<name>.{update, ignore, shallow}') is not specific
to the project setup requirements, but rather is a distribution
of suggested developer configurations.  In other areas of Git
a suggested developer configuration is not transported in-tree
but via other means.  In an organisation this could be done
by deploying an opinionated system wide config (/etc/gitconfig)
or by putting the settings in the users home directory when
they start at the organisation. In open source projects this
is often accomplished via extensive READMEs (cf. our
SubmittingPatches/CodingGuidlines).

As a later patch in this series wants to introduce
a generic submodule recursion option, we want to make
sure that switch is not exposed via the gitmodules file.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/submodule.c b/submodule.c
index c9e764b519..78cccb7563 100644
--- a/submodule.c
+++ b/submodule.c
@@ -153,7 +153,8 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
 	}
 }
 
-int submodule_config(const char *var, const char *value, void *cb)
+/* For loading from the .gitmodules file. */
+static int git_modules_config(const char *var, const char *value, void *cb)
 {
 	if (!strcmp(var, "submodule.fetchjobs")) {
 		parallel_jobs = git_config_int(var, value);
@@ -169,6 +170,12 @@ int submodule_config(const char *var, const char *value, void *cb)
 	return 0;
 }
 
+/* Loads all submodule settings from the config */
+int submodule_config(const char *var, const char *value, void *cb)
+{
+	return git_modules_config(var, value, cb);
+}
+
 int option_parse_recurse_submodules_worktree_updater(const struct option *opt,
 						     const char *arg, int unset)
 {
@@ -222,7 +229,8 @@ void gitmodules_config(void)
 		}
 
 		if (!gitmodules_is_unmerged)
-			git_config_from_file(submodule_config, gitmodules_path.buf, NULL);
+			git_config_from_file(git_modules_config,
+				gitmodules_path.buf, NULL);
 		strbuf_release(&gitmodules_path);
 	}
 }
@@ -233,7 +241,7 @@ void gitmodules_config_sha1(const unsigned char *commit_sha1)
 	unsigned char sha1[20];
 
 	if (gitmodule_sha1_from_commit(commit_sha1, sha1, &rev)) {
-		git_config_from_blob_sha1(submodule_config, rev.buf,
+		git_config_from_blob_sha1(git_modules_config, rev.buf,
 					  sha1, NULL);
 	}
 	strbuf_release(&rev);
-- 
2.13.0.17.g582985b1e4


  parent reply	other threads:[~2017-05-26 19:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 19:10 [PATCHv2 0/8] A reroll of sb/submodule-blanket-recursive Stefan Beller
2017-05-26 19:10 ` [PATCH 1/8] submodule recursing: do not write a config variable twice Stefan Beller
2017-05-26 19:10 ` [PATCH 2/8] submodule test invocation: only pass additional arguments Stefan Beller
2017-05-26 19:10 ` [PATCH 3/8] reset/checkout/read-tree: unify config callback for submodule recursion Stefan Beller
2017-05-26 19:10 ` Stefan Beller [this message]
2017-05-26 19:10 ` [PATCH 5/8] Introduce 'submodule.recurse' option for worktree manipulators Stefan Beller
2017-05-26 19:10 ` [PATCH 6/8] builtin/grep.c: respect 'submodule.recurse' option Stefan Beller
2017-05-26 19:10 ` [PATCH 7/8] builtin/push.c: " Stefan Beller
2017-05-26 19:10 ` [PATCH 8/8] builtin/fetch.c: " Stefan Beller
2017-05-30  5:30 ` [PATCHv2 0/8] A reroll of sb/submodule-blanket-recursive Junio C Hamano
2017-06-01  0:30   ` [PATCHv3 0/4] " Stefan Beller
2017-06-01  0:30     ` [PATCHv3 1/4] Introduce 'submodule.recurse' option for worktree manipulators Stefan Beller
2017-06-01  0:30     ` [PATCHv3 2/4] builtin/grep.c: respect 'submodule.recurse' option Stefan Beller
2017-06-01  0:30     ` [PATCHv3 3/4] builtin/push.c: " Stefan Beller
2017-06-01  0:30     ` [PATCHv3 4/4] builtin/fetch.c: " Stefan Beller

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=20170526191017.19155-5-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).