Allow sending emails only for a subset of refs

Many projects use a pull-request model with a central repository, where
new changes are pushed to branches named e.g. feature/whizbang.  However,
users really don't view these branches as "part of the repository" until
they are merged into a 'real' branch, such as master.  And lots of users
are very annoyed at getting email notifications for pushes to these
branches; they only want to be notified when some subset of branches are
updated.

There's a slight complication, though: traditionally git-multimail has
only sent out commit emails for commits that are entirely new to the
repository, but this doesn't play well with this filtering feature.  So,
we need to instead have git-multimail only send out commit emails for
commits that are entirely new to the *relevant subset of the* repository.

Add multimailhook.refFilterInclusionRegex and
multimailhook.refFilterExclusionRegex configuration options, with related
--ref-filter-inclusion-regex and --ref-filter-exclusion-regex command
line options, which can be used to configure which refs are considered
relevant.  Mark ^refs/notes/ as irrelevant by default as git-multimail
emails make no sense for git notes.

Signed-off-by: Elijah Newren <newren@palantir.com>
testing: Pass additional arguments through test functions to multimail

Signed-off-by: Elijah Newren <newren@palantir.com>
Test restricting emails to a subset of refs defined by exclusion

Signed-off-by: Elijah Newren <newren@palantir.com>
Test restricting emails to a subset of refs defined by inclusion

Signed-off-by: Elijah Newren <newren@palantir.com>
StashEnvironment: New environment for being called from Atlassian Stash

Atlassian Stash can utilize a standard post-receive hook, and thus we
could use git_multimail as-is.  However, that is slightly suboptimal
because: (a) when pull requests are merged in stash, they are done on the
server and thus the normal post-receive hook is not triggered, (b)
everything runs as a single user similar to gitolite, but without a
GL_USER environment variable to rely on, and (c) although stash has
reasonable clone urls that having meaningful names for repositories, the
actual on-disk directories in which the repositories are stored are given
positive integers for names -- that results in a rather meaningless email
subject for the users ("[2093] branch master updated..." rather than
"[PROJ/REPO] branch master updated..."), since they will have no idea what
magic integer happened to be selected for their repository.

We can avoid these problems by making use of Stash's
AsyncPostReceiveRepositoryHook instead of a standard post-receive hook,
since it is triggered in all the right cases and has access to the
appropriate user and repo name.  Add a StashEnvironment for holding this
passed information, and add command line flags that can be passed with
the user and repo name.

Signed-off-by: Elijah Newren <newren@palantir.com>
Atlassian Stash plugin: Initial version

This adds a plugin for Atlassian Stash that will run git_multimail as an
AsyncPostReceiveRepositoryHook (similar to a standard post-receive hook,
but also fires for merges of pull-requests; further, via Stash's Java API
such a hook has access to important data like user and repo name).

This plugin currently provides a single textbox entry of configuration at
the time that a repository owner enables the plugin, in which the
repository owner can provide a comma-separated list of email addresses
that they want the emails sent to.  Other multimail configuration options
are unexposed through the web UI, though they can be configured on a
repository-by-repository basis on the server if an admin sets the
appropriate multimailhook.* configuration setting in the git config file.

Signed-off-by: Elijah Newren <newren@palantir.com>
Atlassian Stash plugin: Add logging capability

Signed-off-by: Carl Myers <cmyers@palantir.com>
Signed-off-by: Elijah Newren <newren@palantir.com>
Atlassian Stash plugin: Providing scaffolding for tests

Signed-off-by: Carl Myers <cmyers@palantir.com>
Signed-off-by: Elijah Newren <newren@palantir.com>
Atlassian Stash plugin: Expose ref filtering from the web UI

Signed-off-by: Elijah Newren <newren@palantir.com>
Atlassian Stash plugin: Default recipients list on project settings page

Signed-off-by: Elijah Newren <newren@palantir.com>