mail.sh: improve show_new_revisions other branches handling
commitaf8d0234fec86485ef2ab071889aa7de29bf7dff
authorKyle J. McKay <mackyle@gmail.com>
Thu, 9 Jun 2016 19:50:21 +0000 (9 12:50 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Thu, 9 Jun 2016 19:50:21 +0000 (9 12:50 -0700)
treea05fb3f165f6aed45a9272343143c1faae3ad22c
parent00fda8316c3744ed37538baa7ae47a5b08fb802b
mail.sh: improve show_new_revisions other branches handling

When showing new revisions for a branch, mail.sh excludes all
revisions that already appear in other branches.  To do this
it needs to specify "--not" <all-the-other-branch-tips>.

Previously it was passing all the other branch tips on the
command line which fails (by exceeding the command line length
limit) in a repository with thousands of branches.

Fix this by using a different mechanism to generate the "--not"
list that uses standard input and avoids the problem.

When computing the other branch tips, it's necessary to exclude
the current branch being processed.  Previously this was done
with a simple "grep -v -F $current_branch".  Unfortunately that
excludes too much when the current branch is, for example,
"refs/heads/foo" and there's another branch named "refs/heads/foobar".

The problem is using -F "$current_branch" instead of
"^$current_branch$".  But the latter would require escaping of any
regex characters to be used safely.

Fix this by switching to awk as the branch name can be passed in
without needing to be escaped and easily used to discard only
full matches.  There is a POSIX grep option that could fix this
as well (-x), but since grep turns out to run just a bit slower
than awk (or sed) we use the awk solution instead.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
taskd/mail.sh