# Support for config wildcards

4 messages from 2007-03-13 to 2007-03-13. Participants: Bill Lear, Junio C Hamano.
Thread: https://gitlist.dev/t/7235

## Bill Lear, 2007-03-13 16:47

Subject: Support for config wildcards
Message-ID: <17910.54683.651029.884390@lisa.zopyra.com>
URL: https://gitlist.dev/e/17910.54683.651029.884390%40lisa.zopyra.com

```
I would like to use our update hook to send email to recipients based
on a branch name pattern.  For example, the "abc" team would get email
for all updates to branches that start with the word "abc".

I would like to write something like this in the config file:

[hooks.mail.recipients]
        xyz.pickle = me, you, betty-sue
        xyz* = joe, jaya, julie
        abc* = mark, nancy, svetlana
        taug* = sridhar, pete, joe
        * = me, you, big-boss

Then, in the update hook, do something like this (very
pseudo-code-ish):

    for key, value in $(git config --get-regexp hooks.mail.recipients*); do
        key=${key#hooks.mail.recipients}
        if $(matches $key $branch); then
            recipients=$value
            break
        fi
    done

Which would allow me to change the mailing list recipients based
on the branch without having to update the update hook each time.

But, apparently at least the '*' and '.' characters are not allowed as
keys, and I can't seem to escape them.

Is there a way to do this sort of thing that I am missing?


Bill

```

## Junio C Hamano, 2007-03-13 17:03

Subject: Re: Support for config wildcards
Message-ID: <7vird5jctl.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vird5jctl.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <17910.54683.651029.884390@lisa.zopyra.com>

```
Bill Lear <rael@zopyra.com> writes:

> Is there a way to do this sort of thing that I am missing?

I think the way the config is designed is to place arbitrary
values as values not variable names.

Perhaps...

	[mymailhook "everything"]
        	recipients = me
                branch = "*"

	[mymailhook "all but xyz"]
        	recipients = alice bob charlie
                branch = "*"
                branch = "!xyz"

```

## Bill Lear, 2007-03-13 18:10

Subject: Re: Support for config wildcards
Message-ID: <17910.59652.481204.872797@lisa.zopyra.com>
URL: https://gitlist.dev/e/17910.59652.481204.872797%40lisa.zopyra.com
In-Reply-To: <7vird5jctl.fsf@assigned-by-dhcp.cox.net>

```
On Tuesday, March 13, 2007 at 10:03:18 (-0700) Junio C Hamano writes:
>Bill Lear <rael@zopyra.com> writes:
>
>> Is there a way to do this sort of thing that I am missing?
>
>I think the way the config is designed is to place arbitrary
>values as values not variable names.
>
>Perhaps...
>
>	[mymailhook "everything"]
>        	recipients = me
>               branch = "*"
>
>	[mymailhook "all but xyz"]
>        	recipients = alice bob charlie
>               branch = "*"
>               branch = "!xyz"

Hmm, so in my example, if I had "abc" and "xyz"-specific lists:

	[mymailhook "abc"]
        	recipients = jim bob janet
                branch = "abc*"

	[mymailhook "xyz"]
        	recipients = alice bob charlie
                branch = "xyz*"

	[mymailhook "everything"]
               recipients = me
               branch = "*"

Then, I might, in the update hook, do this, given a branch for which
to find the recipients ("to", below):

for key, pattern in $(git-config --get-regexp 'mymailhook.*.branch'); do
    label=${key#mailhook.}
    label=${label%.branch}
    if $(matches $pattern $branch); then
       to += $(git-config --get-regexp "mymailhook.${label}.recipients")
    fi
done

But that doesn't work for your example "all but xyz".  I guess in that
case, I would need to check both branch patterns and if one did not
match, then I would reject it and not add to the recipient list.

Was that basically what you had in mind?


Bill

```

## Junio C Hamano, 2007-03-13 19:50

Subject: Re: Support for config wildcards
Message-ID: <7v8xe0j531.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v8xe0j531.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <17910.59652.481204.872797@lisa.zopyra.com>

```
Bill Lear <rael@zopyra.com> writes:

> But that doesn't work for your example "all but xyz".  I guess in that
> case, I would need to check both branch patterns and if one did not
> match, then I would reject it and not add to the recipient list.
>
> Was that basically what you had in mind?

Yes, similar to how positive and negative entries in .gitignore
influences the final outcome of the 'ignoredness' for each path.

```
