All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brandon Williams <bmwill@google.com>
To: git@vger.kernel.org
Cc: Brandon Williams <bmwill@google.com>,
	sbeller@google.com, gitster@pobox.com
Subject: [PATCH v5 00/10] decoupling url and submodule interest
Date: Fri, 17 Mar 2017 15:37:55 -0700	[thread overview]
Message-ID: <20170317223805.95271-1-bmwill@google.com> (raw)
In-Reply-To: <20170316222952.53801-1-bmwill@google.com>

Changes in v5:
  * Add "NEEDSWORK" comments to indicate where attention is needed once
    per-worktree config is a reality
  * --no-recurse now works by clearing the string list of paths.
  * module_list_active() now does post-processing instead of duplicating code.

Brandon Williams (10):
  submodule--helper: add is-active subcommand
  submodule status: use submodule--helper is-active
  submodule sync: skip work for inactive submodules
  submodule sync: use submodule--helper is-active
  submodule--helper clone: check for configured submodules using helper
  submodule: decouple url and submodule interest
  submodule init: initialize active submodules
  clone: teach --recurse-submodules to optionally take a pathspec
  submodule--helper init: set submodule.<name>.active
  submodule add: respect submodule.active and submodule.<name>.active

 Documentation/config.txt        |  15 ++++-
 Documentation/git-clone.txt     |  14 +++--
 Documentation/git-submodule.txt |   4 +-
 builtin/clone.c                 |  50 ++++++++++++---
 builtin/submodule--helper.c     |  68 ++++++++++++++++----
 git-submodule.sh                |  55 ++++++++++------
 submodule.c                     |  50 ++++++++++++---
 t/t7400-submodule-basic.sh      | 136 ++++++++++++++++++++++++++++++++++++++++
 t/t7413-submodule-is-active.sh  | 107 +++++++++++++++++++++++++++++++
 9 files changed, 445 insertions(+), 54 deletions(-)
 create mode 100755 t/t7413-submodule-is-active.sh

---interdiff with 'origin/bw/submodule-is-active'


diff --git a/builtin/clone.c b/builtin/clone.c
index 3dc8faac5..a7be61d6b 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -62,9 +62,8 @@ static int recurse_submodules_cb(const struct option *opt,
 				 const char *arg, int unset)
 {
 	if (unset)
-		return -1;
-
-	if (arg)
+		string_list_clear((struct string_list *)opt->value, 0);
+	else if (arg)
 		string_list_append((struct string_list *)opt->value, arg);
 	else
 		string_list_append((struct string_list *)opt->value,
@@ -984,6 +983,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		string_list_sort(&option_recurse_submodules);
 		string_list_remove_duplicates(&option_recurse_submodules, 0);

+		/*
+		 * NEEDSWORK: In a multi-working-tree world, this needs to be
+		 * set in the per-worktree config.
+		 */
 		for_each_string_list_item(item, &option_recurse_submodules) {
 			strbuf_addf(&sb, "submodule.active=%s",
 				    item->string);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index a574596cb..7700d8948 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -273,29 +273,24 @@ static int module_list_compute(int argc, const char **argv,
 static void module_list_active(struct module_list *list)
 {
 	int i;
-
-	if (read_cache() < 0)
-		die(_("index file corrupt"));
+	struct module_list active_modules = MODULE_LIST_INIT;

 	gitmodules_config();

-	for (i = 0; i < active_nr; i++) {
-		const struct cache_entry *ce = active_cache[i];
+	for (i = 0; i < list->nr; i++) {
+		const struct cache_entry *ce = list->entries[i];

-		if (!S_ISGITLINK(ce->ce_mode) ||
-		    !is_submodule_initialized(ce->name))
+		if (!is_submodule_initialized(ce->name))
 			continue;

-		ALLOC_GROW(list->entries, list->nr + 1, list->alloc);
-		list->entries[list->nr++] = ce;
-		while (i + 1 < active_nr &&
-		       !strcmp(ce->name, active_cache[i + 1]->name))
-			/*
-			 * Skip entries with the same name in different stages
-			 * to make sure an entry is returned only once.
-			 */
-			i++;
+		ALLOC_GROW(active_modules.entries,
+			   active_modules.nr + 1,
+			   active_modules.alloc);
+		active_modules.entries[active_modules.nr++] = ce;
 	}
+
+	free(list->entries);
+	*list = active_modules;
 }

 static int module_list(int argc, const char **argv, const char *prefix)
@@ -361,7 +356,12 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
 		die(_("No url found for submodule path '%s' in .gitmodules"),
 			displaypath);

-	/* Set active flag for the submodule being initialized */
+	/*
+	 * NEEDSWORK: In a multi-working-tree world, this needs to be
+	 * set in the per-worktree config.
+	 *
+	 * Set active flag for the submodule being initialized
+	 */
 	if (!is_submodule_initialized(path)) {
 		strbuf_reset(&sb);
 		strbuf_addf(&sb, "submodule.%s.active", sub->name);
@@ -452,14 +452,15 @@ static int module_init(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, module_init_options,
 			     git_submodule_helper_usage, 0);

+	if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
+		return 1;
+
 	/*
 	 * If there are no path args and submodule.active is set then,
 	 * by default, only initialize 'active' modules.
 	 */
 	if (!argc && git_config_get_value_multi("submodule.active"))
 		module_list_active(&list);
-	else if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
-		return 1;

 	for (i = 0; i < list.nr; i++)
 		init_submodule(list.entries[i]->name, prefix, quiet);
diff --git a/git-submodule.sh b/git-submodule.sh
index 6eca93416..6ec35e5fc 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -279,6 +279,8 @@ or you are unsure what this means choose another name with the '--name' option."
 	git add --force .gitmodules ||
 	die "$(eval_gettext "Failed to register submodule '\$sm_path'")"

+	# NEEDSWORK: In a multi-working-tree world, this needs to be
+	# set in the per-worktree config.
 	if git config --get submodule.active >/dev/null
 	then
 		# If the submodule being adding isn't already covered by the

--
2.12.0.367.g23dc2f6d3c-goog


  parent reply	other threads:[~2017-03-18  0:41 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
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       ` Brandon Williams [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170317223805.95271-1-bmwill@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.