From: Brandon Williams <bmwill@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, sbeller@google.com
Subject: Re: [PATCH v3 05/10] submodule: decouple url and submodule existence
Date: Wed, 15 Mar 2017 14:37:37 -0700 [thread overview]
Message-ID: <20170315213737.GC159137@google.com> (raw)
In-Reply-To: <xmqqzignittf.fsf@gitster.mtv.corp.google.com>
On 03/14, Junio C Hamano wrote:
> Brandon Williams <bmwill@google.com> writes:
>
> > Currently the submodule.<name>.url config option is used to determine
> > if a given submodule exists and is interesting to the user. This
> > however doesn't work very well because the URL is a config option for
> > the scope of a repository, whereas the existence of a submodule is an
> > option scoped to the working tree.
>
> A submodule exists if it is exists, whether the user is interested
> in it or not. If it should be checked out in the working tree is a
> different matter, but that should be a logical AND between "is it of
> interest?" and "is the superproject tree has a gitlink for it in its
> working tree?".
>
> So I do not agree with "This however doesn't work" at all. I'd
> understand it if you said "This is cumbersome if we want to do this
> and that, which are different from what we have done traditionally"
> and explain what this and that are and how they are different.
>
> > In a future with worktree support for submodules, there will be multiple
> > working trees, each of which may only need a subset of the submodules
> > checked out. The URL (which is where the submodule repository can be
> > obtained) should not differ between different working trees.
>
> And this makes the motivation a bit clearer. When the user wants to
> have multiple worktrees for the same superproject. In such a
> setting, the same submodule in two worktrees typically want to have
> the same URL. It may be different from what the upstream suggests
> in the .gitmodules file, but the difference, i.e. the site specific
> customization of the URL, should be the same between the two
> worktrees. But one worktree may be and the other worktree may not be
> interested in that submodule, and with shared .git/config file, you
> cannot have submodule.<name>.url set to one value and unset at the
> same time.
>
> This series does not solve the "two worktrees cannot have private
> parts in the configuration namespace" issue, but assuming it will be
> solved by some other series, it anticipates that submodule.<name>.URL
> would want to be shared between two worktrees most of time (note that
> there will be users who want two separate .URL for the same submodule
> while sharing the object database via worktrees mechanism, and you'll
> need to prepare for them, too), and another "bit" that tells if the
> submodule is of interest would want to be private to each worktree.
>
> That is the motivation, the reason why you want .URL to stop serving
> the dual purpose of overriding upstream-suggested URL and indicating
> the submodule is interesting to the user.
>
> > It may also be convenient for users to more easily specify groups of
> > submodules they are interested in as apposed to running "git submodule
> > init <path>" on each submodule they want checked out in their working
> > tree.
> >
> > To this end two config options are introduced, submodule.active and
> > submodule.<name>.active. The submodule.active config holds a pathspec
> > that specifies which submodules should exist in the working tree. The
> > submodule.<name>.active config is a boolean flag used to indicate if
> > that particular submodule should exist in the working tree.
>
> And because two worktrees always share their .git/config, these new
> configuration variables are useless to help workflow with multiple
> worktrees with the current system, until "per-worktree configuration"
> is invented. But we prepare for that future in this step.
>
> Also submodule.active that takes pathspec and not name is an oddball
> (use of "name" not "path" is to prepare for a submodule whose
> location in the superproject changes depending on the commit in the
> superproject), and we need to justify with an explanation. I think
> you envision two cases. 1. we encourage projects to adopt a
> convention that submodules are grouped with leading directory, so
> that pathspec e.g. lib/, would cover _all_ library-ish modules to
> allow those who are interested in library-ish modules to set
> ".active = lib/" just once to say any and all modules in lib/ are
> interesting. 2. another convention the projects can adopt, when
> pathspec-attribute feature is invented, is to label submodules with
> attribute to group them, so that a broad pathspec with attribute
> requirement, e.g. .:(attr:lib), can be used to say any and all
> modules with 'lib' attribute are interesting.
>
> The above two points (justifications, intended uses and future
> plans) need to be clarified around here (and possibly in the
> documentation), I would think.
I'll overhaul this to better explain the intentions behind the change.
Thanks for pointing out what needs a more detailed explanation.
>
> > diff --git a/submodule.c b/submodule.c
> > index 0a2831d84..2b33bd70f 100644
> > --- a/submodule.c
> > +++ b/submodule.c
> > @@ -217,13 +217,41 @@ void gitmodules_config_sha1(const unsigned char *commit_sha1)
> > int is_submodule_initialized(const char *path)
> > {
> > int ret = 0;
> > - const struct submodule *module = NULL;
> > + char *key;
> > + const struct string_list *sl;
> > + const struct submodule *module = submodule_from_path(null_sha1, path);
> >
> > - module = submodule_from_path(null_sha1, path);
> > + /* early return if there isn't a path->module mapping */
> > + if (!module)
> > + return 0;
> > +
> > + /* submodule.<name>.active is set */
> > + key = xstrfmt("submodule.%s.active", module->name);
> > + if (!git_config_get_bool(key, &ret)) {
> > + free(key);
> > + return ret;
> > + }
> > + free(key);
> > +
> > + sl = git_config_get_value_multi("submodule.active");
> >
> > - if (module) {
> > - char *key = xstrfmt("submodule.%s.url", module->name);
> > + if (sl) {
> > + struct pathspec ps;
> > + struct argv_array args = ARGV_ARRAY_INIT;
> > + const struct string_list_item *item;
> > +
> > + for_each_string_list_item(item, sl) {
> > + argv_array_push(&args, item->string);
> > + }
> > +
> > + parse_pathspec(&ps, 0, 0, 0, args.argv);
> > + ret = match_pathspec(&ps, path, strlen(path), 0, NULL, 1);
> > +
> > + argv_array_clear(&args);
> > + clear_pathspec(&ps);
> > + } else {
> > char *value = NULL;
> > + key = xstrfmt("submodule.%s.url", module->name);
> >
> > ret = !git_config_get_string(key, &value);
>
> It probably is easier to read if you had a final "return ret" in the
> "if (sl) {...}" part, just like you have one for the codepath that
> deals with "submodule.<name>.active", and flatten the else clause.
> That would make it clear that we have three ways with decreasing
> precedence.
Sounds like a good change. I'm all for making the code more readable.
>
> At this point, the answer from function is even less about "is it
> initialized?" but about "is it of interest?" (or "is it to be
> initialized?"). We'd probably want a /* NEEDSWORK */ comment before
> the function to remind us to come up with a better name after the
> dust settles.
Yeah I expect we should rename it to 'is_submodule_active' at some
point, or something along those lines.
>
> > diff --git a/t/t7413-submodule-is-active.sh b/t/t7413-submodule-is-active.sh
> > index f18e0c925..c41b899ab 100755
> > --- a/t/t7413-submodule-is-active.sh
> > +++ b/t/t7413-submodule-is-active.sh
> > @@ -28,4 +28,59 @@ test_expect_success 'is-active works with urls' '
> > git -C super submodule--helper is-active sub1
> > '
> >
> > +test_expect_success 'is-active works with submodule.<name>.active config' '
> > + git -C super config --bool submodule.sub1.active "false" &&
> > + test_must_fail git -C super submodule--helper is-active sub1 &&
> > +
> > + git -C super config --bool submodule.sub1.active "true" &&
> > + git -C super config --unset submodule.sub1.URL &&
> > + git -C super submodule--helper is-active sub1 &&
> > +
> > + git -C super config submodule.sub1.URL ../sub &&
> > + git -C super config --unset submodule.sub1.active
> > +'
>
> The last "unset" is done to clean the customization this test did,
> in order to give a predictable beginning state to the next test? If
> so, use test_when_finished instead of &&-cascading it at the end.
Will do.
>
> > + ...
> > +test_expect_success 'is-active with submodule.active and submodule.<name>.active' '
> > + git -C super config --add submodule.active "sub1" &&
> > + git -C super config --bool submodule.sub1.active "false" &&
> > + git -C super config --bool submodule.sub2.active "true" &&
> > +
> > + test_must_fail git -C super submodule--helper is-active sub1 &&
> > + git -C super submodule--helper is-active sub2 &&
> > +
> > + git -C super config --unset-all submodule.active &&
> > + git -C super config --unset submodule.sub1.active &&
> > + git -C super config --unset submodule.sub2.active
> > +'
>
> Likewise for all the new tests in this patch.
>
> Thanks.
--
Brandon Williams
next prev parent reply other threads:[~2017-03-15 21:37 UTC|newest]
Thread overview: 123+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 23:47 [PATCH 00/10] decoupling a submodule's existence and its url Brandon Williams
2017-02-23 23:47 ` [PATCH 01/10] submodule: decouple url and submodule existence Brandon Williams
2017-02-24 21:02 ` Junio C Hamano
2017-03-01 20:02 ` Brandon Williams
2017-03-01 21:53 ` Stefan Beller
2017-03-06 18:50 ` Brandon Williams
2017-03-02 5:43 ` Junio C Hamano
2017-02-23 23:47 ` [PATCH 02/10] submodule update: add `--init-active` switch Brandon Williams
2017-02-23 23:47 ` [PATCH 03/10] clone: add --submodule-spec=<pathspec> switch Brandon Williams
2017-02-23 23:47 ` [PATCH 04/10] completion: clone can initialize specific submodules Brandon Williams
2017-02-23 23:47 ` [PATCH 05/10] submodule--helper: add is_active command Brandon Williams
2017-02-24 1:15 ` Stefan Beller
2017-02-27 18:35 ` Brandon Williams
2017-02-23 23:47 ` [PATCH 06/10] submodule add: respect submodule.active Brandon Williams
2017-02-23 23:47 ` [PATCH 07/10] submodule status: use submodule--helper is-active Brandon Williams
2017-02-23 23:47 ` [PATCH 08/10] submodule deinit: use most reliable url Brandon Williams
2017-02-23 23:47 ` [PATCH 09/10] submodule sync: use submodule--helper is-active Brandon Williams
2017-02-23 23:47 ` [PATCH 10/10] submodule--helper clone: check for configured submodules using helper Brandon Williams
2017-02-24 0:58 ` Stefan Beller
2017-02-27 18:38 ` Brandon Williams
2017-02-23 23:58 ` [PATCH 00/10] decoupling a submodule's existence and its url Stefan Beller
2017-03-09 1:23 ` [PATCH v2 00/11] " Brandon Williams
2017-03-09 1:23 ` [PATCH v2 01/11] submodule--helper: add is_active command Brandon Williams
2017-03-09 1:23 ` [PATCH v2 02/11] submodule status: use submodule--helper is-active Brandon Williams
2017-03-09 1:23 ` [PATCH v2 03/11] submodule deinit: use most reliable url Brandon Williams
2017-03-09 1:56 ` Stefan Beller
2017-03-09 18:15 ` Brandon Williams
2017-03-09 1:23 ` [PATCH v2 04/11] submodule sync: use submodule--helper is-active Brandon Williams
2017-03-09 1:23 ` [PATCH v2 05/11] submodule--helper clone: check for configured submodules using helper Brandon Williams
2017-03-09 1:23 ` [PATCH v2 06/11] submodule: decouple url and submodule existence Brandon Williams
2017-03-09 1:23 ` [PATCH v2 07/11] submodule update: add `--init-active` switch Brandon Williams
2017-03-09 2:16 ` Stefan Beller
2017-03-09 18:08 ` Brandon Williams
2017-03-09 1:23 ` [PATCH v2 08/11] clone: add --submodule-spec=<pathspec> switch Brandon Williams
2017-03-09 1:23 ` [PATCH v2 09/11] completion: clone can initialize specific submodules Brandon Williams
2017-03-09 1:23 ` [PATCH v2 10/11] submodule--helper init: set submodule.<name>.active Brandon Williams
2017-03-09 2:28 ` Stefan Beller
2017-03-09 17:56 ` Brandon Williams
2017-03-09 1:23 ` [PATCH v2 11/11] submodule add: respect submodule.active and submodule.<name>.active Brandon Williams
2017-03-13 21:43 ` [PATCH v3 00/10] decoupling a submodule's existence and its url Brandon Williams
2017-03-13 21:43 ` [PATCH v3 01/10] submodule--helper: add is_active command Brandon Williams
2017-03-13 22:36 ` Stefan Beller
2017-03-14 17:40 ` Junio C Hamano
2017-03-14 22:44 ` Brandon Williams
2017-03-13 21:43 ` [PATCH v3 02/10] submodule status: use submodule--helper is-active Brandon Williams
2017-03-14 17:46 ` Junio C Hamano
2017-03-14 18:16 ` Stefan Beller
2017-03-14 20:20 ` Junio C Hamano
2017-03-14 21:33 ` Junio C Hamano
2017-03-14 22:50 ` Brandon Williams
2017-03-14 23:36 ` Brandon Williams
2017-03-13 21:43 ` [PATCH v3 03/10] submodule sync: " Brandon Williams
2017-03-14 17:53 ` Junio C Hamano
2017-03-14 23:50 ` Brandon Williams
2017-03-13 21:43 ` [PATCH v3 04/10] submodule--helper clone: check for configured submodules using helper Brandon Williams
2017-03-14 18:06 ` Junio C Hamano
2017-03-14 18:40 ` Stefan Beller
2017-03-14 20:25 ` Junio C Hamano
2017-03-15 0:10 ` Brandon Williams
2017-03-13 21:43 ` [PATCH v3 05/10] submodule: decouple url and submodule existence Brandon Williams
2017-03-13 22:49 ` Stefan Beller
2017-03-15 17:38 ` Brandon Williams
2017-03-14 18:42 ` Junio C Hamano
2017-03-14 21:38 ` Junio C Hamano
2017-03-15 21:37 ` Brandon Williams [this message]
2017-03-13 21:43 ` [PATCH v3 06/10] submodule update: add `--init-active` switch Brandon Williams
2017-03-14 19:18 ` Junio C Hamano
2017-03-15 21:52 ` Brandon Williams
2017-03-14 19:28 ` Junio C Hamano
2017-03-15 21:42 ` Brandon Williams
2017-03-13 21:43 ` [PATCH v3 07/10] clone: add --submodule-spec=<pathspec> switch Brandon Williams
2017-03-14 19:38 ` Junio C Hamano
2017-03-15 23:08 ` Brandon Williams
2017-03-15 23:25 ` Stefan Beller
2017-03-13 21:43 ` [PATCH v3 08/10] completion: clone can initialize specific submodules Brandon Williams
2017-03-13 21:43 ` [PATCH v3 09/10] submodule--helper init: set submodule.<name>.active Brandon Williams
2017-03-14 19:43 ` Junio C Hamano
2017-03-15 22:46 ` Brandon Williams
2017-03-16 16:47 ` Junio C Hamano
2017-03-13 21:43 ` [PATCH v3 10/10] submodule add: respect submodule.active and submodule.<name>.active Brandon Williams
2017-03-14 19:48 ` Junio C Hamano
2017-03-15 21:59 ` Brandon Williams
2017-03-13 22:51 ` [PATCH v3 00/10] decoupling a submodule's existence and its url Stefan Beller
2017-03-14 21:40 ` Junio C Hamano
2017-03-14 22:17 ` Brandon Williams
2017-03-16 22:29 ` [PATCH v4 00/10] decoupling url and submodule interest Brandon Williams
2017-03-16 22:29 ` [PATCH v4 01/10] submodule--helper: add is-active subcommand Brandon Williams
2017-03-16 22:29 ` [PATCH v4 02/10] submodule status: use submodule--helper is-active Brandon Williams
2017-03-16 22:29 ` [PATCH v4 03/10] submodule sync: skip work for inactive submodules Brandon Williams
2017-03-16 23:24 ` Stefan Beller
2017-03-16 23:25 ` Stefan Beller
2017-03-16 23:26 ` Brandon Williams
2017-03-17 5:26 ` Junio C Hamano
2017-03-17 6:58 ` Brandon Williams
2017-03-17 17:28 ` Junio C Hamano
2017-03-16 22:29 ` [PATCH v4 04/10] submodule sync: use submodule--helper is-active Brandon Williams
2017-03-16 22:29 ` [PATCH v4 05/10] submodule--helper clone: check for configured submodules using helper Brandon Williams
2017-03-16 22:29 ` [PATCH v4 06/10] submodule: decouple url and submodule interest Brandon Williams
2017-03-16 23:45 ` Stefan Beller
2017-03-16 22:29 ` [PATCH v4 07/10] submodule init: initialize active submodules Brandon Williams
2017-03-17 18:17 ` Stefan Beller
2017-03-17 22:28 ` Brandon Williams
2017-03-17 23:25 ` Stefan Beller
2017-03-16 22:29 ` [PATCH v4 08/10] clone: teach --recurse-submodules to optionally take a pathspec Brandon Williams
2017-03-17 17:37 ` Stefan Beller
2017-03-17 21:28 ` Brandon Williams
2017-03-16 22:29 ` [PATCH v4 09/10] submodule--helper init: set submodule.<name>.active Brandon Williams
2017-03-17 17:22 ` Stefan Beller
2017-03-17 21:55 ` Brandon Williams
2017-03-16 22:29 ` [PATCH v4 10/10] submodule add: respect submodule.active and submodule.<name>.active Brandon Williams
2017-03-17 22:37 ` [PATCH v5 00/10] decoupling url and submodule interest Brandon Williams
2017-03-17 22:37 ` [PATCH v5 01/10] submodule--helper: add is-active subcommand Brandon Williams
2017-03-17 22:37 ` [PATCH v5 02/10] submodule status: use submodule--helper is-active Brandon Williams
2017-03-17 22:37 ` [PATCH v5 03/10] submodule sync: skip work for inactive submodules Brandon Williams
2017-03-17 22:37 ` [PATCH v5 04/10] submodule sync: use submodule--helper is-active Brandon Williams
2017-03-17 22:38 ` [PATCH v5 05/10] submodule--helper clone: check for configured submodules using helper Brandon Williams
2017-03-17 22:38 ` [PATCH v5 06/10] submodule: decouple url and submodule interest Brandon Williams
2017-03-17 22:38 ` [PATCH v5 07/10] submodule init: initialize active submodules Brandon Williams
2017-03-17 22:38 ` [PATCH v5 08/10] clone: teach --recurse-submodules to optionally take a pathspec Brandon Williams
2017-03-17 22:38 ` [PATCH v5 09/10] submodule--helper init: set submodule.<name>.active Brandon Williams
2017-03-17 22:38 ` [PATCH v5 10/10] submodule add: respect submodule.active and submodule.<name>.active Brandon Williams
2017-03-17 23:25 ` [PATCH v5 00/10] decoupling url and submodule interest Stefan Beller
2017-03-18 17:00 ` Junio C Hamano
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=20170315213737.GC159137@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.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).