From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: Jens.Lehmann@web.de, sschuberth@gmail.com, git@vger.kernel.org
Subject: Re: [RFC_PATCHv4 3/7] submodule-config: add method to check for being labeled
Date: Tue, 22 Mar 2016 15:30:04 -0700 [thread overview]
Message-ID: <xmqqegb2f8nn.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1458612372-10966-4-git-send-email-sbeller@google.com> (Stefan Beller's message of "Mon, 21 Mar 2016 19:06:08 -0700")
Stefan Beller <sbeller@google.com> writes:
> In later patches we need to tell if a submodule is labeled by
> the given labels.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
Hmph, I would have expected that something like this would touch the
module_list() implementation. Probably that would happen in future
steps, I guess?
> submodule-config.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> submodule-config.h | 3 +++
> 2 files changed, 51 insertions(+)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index 7b48e59..b10a773 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -493,3 +493,51 @@ void submodule_free(void)
> cache_free(&cache);
> is_cache_init = 0;
> }
> +
> +int submodule_applicable_by_labels(const struct string_list *list,
> + const struct submodule *sub)
> +{
> + int label_apply = 0;
> + struct strbuf sb = STRBUF_INIT;
> +
> + if (!list)
> + return 1;
> +
> + if (sub->labels) {
> + struct string_list_item *item;
> + for_each_string_list_item(item, sub->labels) {
> + strbuf_reset(&sb);
> + strbuf_addf(&sb, "*%s", item->string);
> + if (string_list_has_string(list, sb.buf)) {
> + label_apply = 1;
> + break;
> + }
> + }
> + }
> + if (sub->path) {
> + /*
> + * NEEDSWORK: This currently works only for
> + * exact paths, but we want to enable
> + * inexact matches such wildcards.
> + */
> + strbuf_reset(&sb);
> + strbuf_addf(&sb, "./%s", sub->path);
> + if (string_list_has_string(list, sb.buf)) {
> + label_apply = 1;
> + }
> + }
> + if (sub->name) {
> + /*
> + * NEEDSWORK: Same as with path. Do we want to
> + * support wildcards or such?
> + */
> + strbuf_reset(&sb);
> + strbuf_addf(&sb, ":%s", sub->name);
> + if (string_list_has_string(list, sb.buf)) {
> + label_apply = 1;
> + }
> + }
> + strbuf_release(&sb);
> +
> + return label_apply;
> +}
> diff --git a/submodule-config.h b/submodule-config.h
> index 8d61df3..d67f666 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -30,4 +30,7 @@ const struct submodule *submodule_from_path(const unsigned char *commit_sha1,
> const char *path);
> void submodule_free(void);
>
> +int submodule_applicable_by_labels(const struct string_list *list,
> + const struct submodule *sub);
> +
> #endif /* SUBMODULE_CONFIG_H */
next prev parent reply other threads:[~2016-03-22 22:30 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 [this message]
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 ` [RFC_PATCHv4 7/7] WIP status/diff: respect submodule.actionOnLabel 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqegb2f8nn.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=sbeller@google.com \
--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 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.