git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brandon Williams <bmwill@google.com>
To: Stefan Beller <sbeller@google.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH 05/10] submodule--helper: add is_active command
Date: Mon, 27 Feb 2017 10:35:36 -0800	[thread overview]
Message-ID: <20170227183536.GD153455@google.com> (raw)
In-Reply-To: <CAGZ79kZKH_e2NLd=A=og452f-1bfFcSoi5=SM5oetu87TT766Q@mail.gmail.com>

On 02/23, Stefan Beller wrote:
> On Thu, Feb 23, 2017 at 3:47 PM, Brandon Williams <bmwill@google.com> wrote:
> > There are a lot of places where an explicit check for
> > submodule."<name>".url is done to see if a submodule exists.  In order
> > to more easily facilitate the use of the submodule.active config option
> > to indicate active submodules, add a helper which can be used to query
> > if a submodule is active or not.
> >
> > Signed-off-by: Brandon Williams <bmwill@google.com>
> > ---
> >  builtin/submodule--helper.c    | 11 ++++++++
> >  t/t7413-submodule-is-active.sh | 63 ++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 74 insertions(+)
> >  create mode 100755 t/t7413-submodule-is-active.sh
> >
> > diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> > index df0d9c166..dac02604d 100644
> > --- a/builtin/submodule--helper.c
> > +++ b/builtin/submodule--helper.c
> > @@ -1128,6 +1128,16 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
> >         return 0;
> >  }
> >
> > +static int is_active(int argc, const char **argv, const char *prefix)
> > +{
> > +       if (argc != 2)
> > +               die("submodule--helper is-active takes exactly 1 arguments");
> > +
> > +       gitmodules_config();
> > +
> > +       return !is_submodule_initialized(argv[1]);
> > +}
> > +
> >  #define SUPPORT_SUPER_PREFIX (1<<0)
> >
> >  struct cmd_struct {
> > @@ -1147,6 +1157,7 @@ static struct cmd_struct commands[] = {
> >         {"init", module_init, 0},
> >         {"remote-branch", resolve_remote_submodule_branch, 0},
> >         {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX},
> > +       {"is-active", is_active, 0},
> >  };
> >
> >  int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
> > diff --git a/t/t7413-submodule-is-active.sh b/t/t7413-submodule-is-active.sh
> > new file mode 100755
> > index 000000000..683487020
> > --- /dev/null
> > +++ b/t/t7413-submodule-is-active.sh
> > @@ -0,0 +1,63 @@
> > +#!/bin/sh
> > +
> > +test_description='Test submodule--helper is-active
> > +
> > +This test verifies that `git submodue--helper is-active` correclty identifies
> > +submodules which are "active" and interesting to the user.
> > +'
> > +
> > +. ./test-lib.sh
> > +
> > +test_expect_success 'setup' '
> > +       git init sub &&
> > +       test_commit -C sub initial &&
> > +       git init super &&
> > +       test_commit -C super initial &&
> > +       git -C super submodule add ../sub sub1 &&
> > +       git -C super submodule add ../sub sub2 &&
> > +       git -C super commit -a -m "add 2 submodules at sub{1,2}"
> > +'
> > +
> > +test_expect_success 'is-active works with urls' '
> > +       git -C super submodule--helper is-active sub1 &&
> > +       git -C super submodule--helper is-active sub2 &&
> > +
> > +       git -C super config --unset submodule.sub1.URL &&
> > +       test_must_fail git -C super submodule--helper is-active sub1 &&
> > +       git -C super config submodule.sub1.URL ../sub &&
> > +       git -C super submodule--helper is-active sub1
> > +'
> > +
> > +test_expect_success 'is-active works with basic submodule.active config' '
> > +       git -C super config --add submodule.active "." &&
> > +       git -C super config --unset submodule.sub1.URL &&
> > +       git -C super config --unset submodule.sub2.URL &&
> 
> I think we'd want to unset only one of them here
> 
> > +
> > +       git -C super submodule--helper is-active sub1 &&
> > +       git -C super submodule--helper is-active sub2 &&
> 
> to test 2 different cases of one being active by config setting only and
> the other having both.

Will do.

> 
> I could not spot test for having the URL set but the config setting set, not
> including the submodule, e.g.
> 
>     git -C super config  submodule.sub1.URL ../sub &&
>     git -C super submodule.active  ":(exclude)sub1" &&
> 
> which would be expected to not be active, as once the configuration
> is there it takes precedence over any (no)URL setting?

The last test, tests this functionality as the URL settings for both
sub1 and sub2 are in the config.  You'll notice in the tests where I
unset the URL config, that they get added back at the end of the test so
that future tests have a clean state to work with.

-- 
Brandon Williams

  reply	other threads:[~2017-02-27 22:35 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 [this message]
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
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=20170227183536.GD153455@google.com \
    --to=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --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).