refactor 1st line matching for branches containing dots

There is now 1 rule for the 1st line which combines the logic
of the previously 3 rules for the 1st line and uses the match(...)
function to pick between the 3 cases.  The main motivation is to
allow dots in branch names (e.g. release-1.0), which requires
the 3 cases for the 1st line to be mutually exclusive in order to
handle all cases.  Also, using match() as a rule resulted in $0
to be output whenever the rule matched, which is why it was also
moved into a single rule.