git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: bmwill@google.com, jrnieder@gmail.com,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH 3/7] submodule: is_submodule_active to differentiate between new and old mode
Date: Wed, 15 Aug 2018 19:30:56 -0700	[thread overview]
Message-ID: <20180816023100.161626-4-sbeller@google.com> (raw)
In-Reply-To: <20180816023100.161626-1-sbeller@google.com>

The change a086f921a72 (submodule: decouple url and submodule interest,
2017-03-17) enables us to do more than originally thought.
As the url setting was used both to actually set the url where to
obtain the submodule from, as well as used as a boolean flag later
to see if it was active, we would need to keep the url around.

Now that submodules can be activated using the submodule.[<name>.]active
setting, we could remove the url if the submodule is activated via that
setting.

In preparation to do so, pave the way by providing an easy way to see
if a submodule is considered active via the new .active setting or via
the old .url setting.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c | 5 +----
 submodule.h | 6 ++++++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/submodule.c b/submodule.c
index 6e14547e9e0..d56350ed094 100644
--- a/submodule.c
+++ b/submodule.c
@@ -221,9 +221,6 @@ int option_parse_recurse_submodules_worktree_updater(const struct option *opt,
 	return 0;
 }
 
-/*
- * Determine if a submodule has been initialized at a given 'path'
- */
 int is_submodule_active(struct repository *repo, const char *path)
 {
 	int ret = 0;
@@ -267,7 +264,7 @@ int is_submodule_active(struct repository *repo, const char *path)
 
 	/* fallback to checking if the URL is set */
 	key = xstrfmt("submodule.%s.url", module->name);
-	ret = !repo_config_get_string(repo, key, &value);
+	ret = !repo_config_get_string(repo, key, &value) ? 2 : 0;
 
 	free(value);
 	free(key);
diff --git a/submodule.h b/submodule.h
index 4644683e6cb..bfc070e4629 100644
--- a/submodule.h
+++ b/submodule.h
@@ -45,6 +45,12 @@ extern int git_default_submodule_config(const char *var, const char *value, void
 struct option;
 int option_parse_recurse_submodules_worktree_updater(const struct option *opt,
 						     const char *arg, int unset);
+/*
+ * Determine if a submodule has been initialized at a given 'path'.
+ * Returns 1 if it is considered active via the submodule.[<name>.]active
+ * setting, or return 2 if it is active via the older submodule.url setting.
+ */
+#define SUBMODULE_ACTIVE_VIA_URL 2
 extern int is_submodule_active(struct repository *repo, const char *path);
 /*
  * Determine if a submodule has been populated at a given 'path' by checking if
-- 
2.18.0.265.g16de1b435c9.dirty


  parent reply	other threads:[~2018-08-16  2:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16  2:30 [RFC PATCH 0/7] Unset the submodule URL in the superproject when no longer needed Stefan Beller
2018-08-16  2:30 ` [PATCH 1/7] t7410: update to new style Stefan Beller
2018-08-16 17:06   ` Junio C Hamano
2018-08-16  2:30 ` [PATCH 2/7] builtin/submodule--helper: remove stray new line Stefan Beller
2018-08-16  2:30 ` Stefan Beller [this message]
2018-08-16 17:37   ` [PATCH 3/7] submodule: is_submodule_active to differentiate between new and old mode Junio C Hamano
2018-08-20 19:50     ` Stefan Beller
2018-08-21 21:39       ` Junio C Hamano
2018-08-16  2:30 ` [PATCH 4/7] submodule sync: omit setting submodule URL in config if possible Stefan Beller
2018-08-16  2:30 ` [PATCH 5/7] submodule--helper: factor out allocation of callback cookie Stefan Beller
2018-08-16  2:30 ` [PATCH 6/7] submodule--helper, update_clone: store index to update_clone instead of ce Stefan Beller
2018-08-16  2:31 ` [PATCH 7/7] builtin/submodule--helper: unset submodule url if possible Stefan Beller
2018-08-16 15:12 ` [RFC PATCH 0/7] Unset the submodule URL in the superproject when no longer needed Junio C Hamano
2018-08-16 15:45   ` 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=20180816023100.161626-4-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.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).