git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Jens.Lehmann@web.de, sschuberth@gmail.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [RFC_PATCHv4 7/7] WIP status/diff: respect submodule.actionOnLabel
Date: Mon, 21 Mar 2016 19:06:12 -0700	[thread overview]
Message-ID: <1458612372-10966-8-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <1458612372-10966-1-git-send-email-sbeller@google.com>

When 'submodule.actionOnLabel' is set, submodules which are selected by
a label will be inspected in status and diff. If a submodule is not
selected, it is ignored.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c                | 15 +++++++++++++++
 t/t7400-submodule-basic.sh | 13 +++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/submodule.c b/submodule.c
index 458189c..86c0a49 100644
--- a/submodule.c
+++ b/submodule.c
@@ -20,6 +20,8 @@ static struct string_list changed_submodule_paths;
 static int initialized_fetch_ref_tips;
 static struct sha1_array ref_tips_before_fetch;
 static struct sha1_array ref_tips_after_fetch;
+static struct string_list action_labels = STRING_LIST_INIT_DUP;
+static int use_action_labels;
 
 /*
  * The following flag is set if the .gitmodules file is unmerged. We then
@@ -161,10 +163,20 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
 {
 	const struct submodule *submodule = submodule_from_path(null_sha1, path);
 	if (submodule) {
+		char *ignoreMode;
 		if (submodule->ignore)
 			handle_ignore_submodules_arg(diffopt, submodule->ignore);
 		else if (gitmodules_is_unmerged)
 			DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
+
+		if (!use_action_labels)
+			return;
+
+		if (submodule_applicable_by_labels(&action_labels, submodule))
+			ignoreMode = "none";
+		else
+			ignoreMode = "all";
+		handle_ignore_submodules_arg(diffopt, ignoreMode);
 	}
 }
 
@@ -175,6 +187,9 @@ int submodule_config(const char *var, const char *value, void *cb)
 		if (parallel_jobs < 0)
 			die(_("negative values not allowed for submodule.fetchJobs"));
 		return 0;
+	} else if (!strcmp(var, "submodule.actiononlabel")) {
+		use_action_labels = 1;
+		string_list_append(&action_labels, value);
 	} else if (starts_with(var, "submodule."))
 		return parse_submodule_config_option(var, value);
 	else if (!strcmp(var, "fetch.recursesubmodules")) {
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 58da5c4..52ea3c6 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -1281,4 +1281,17 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
 	test_cmp actual expected2
 '
 
+test_expect_success 'status ignores unlabeled submodules' '
+	# Add submodules with and without label
+	# perform a change on disk
+	# observe the change indicated by git status
+	# the submodule not in the label system is ignored.
+	true && true
+'
+
+test_expect_success 'diff applies to action-on-label selection' '
+	# similar to status
+	true && true
+'
+
 test_done
-- 
2.7.0.rc0.45.g6b4c145

      parent reply	other threads:[~2016-03-22  2:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22  2:06 [RFC_PATCHv4 0/7] Git submodule labels Stefan Beller
2016-03-22  2:06 ` [RFC_PATCHv4 1/7] git submodule: teach `add` to label submodules Stefan Beller
2016-03-22 22:28   ` Junio C Hamano
2016-03-22 22:34   ` Junio C Hamano
2016-03-22  2:06 ` [RFC_PATCHv4 2/7] submodule-config: keep labels around Stefan Beller
2016-03-22  2:06 ` [RFC_PATCHv4 3/7] submodule-config: add method to check for being labeled Stefan Beller
2016-03-22 22:30   ` Junio C Hamano
2016-03-23 21:05     ` Stefan Beller
2016-03-22  2:06 ` [RFC_PATCHv4 4/7] submodule init: redirect stdout to stderr Stefan Beller
2016-03-22  7:46   ` Sebastian Schuberth
2016-03-22 16:14     ` Junio C Hamano
2016-03-22 16:47       ` Stefan Beller
2016-03-22 16:56         ` Sebastian Schuberth
2016-03-22 17:15       ` Junio C Hamano
2016-03-22  2:06 ` [RFC_PATCHv4 5/7] submodule update: respect submodule.actionOnLabel Stefan Beller
2016-03-22 22:40   ` Junio C Hamano
2016-03-23 23:21     ` Stefan Beller
2016-03-24  0:13       ` Junio C Hamano
2016-03-24 19:54         ` Stefan Beller
2016-03-24 21:14           ` Junio C Hamano
2016-03-22  2:06 ` [RFC_PATCHv4 6/7] clone: allow specification of submodules to be cloned Stefan Beller
2016-03-22  2:06 ` Stefan Beller [this message]

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=1458612372-10966-8-git-send-email-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=sschuberth@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.
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 NNTP newsgroup(s).