I\'m developing a git post-receive hook in Python. Data is supplied on stdin with lines similar to
ef4d4037f8568e386629457d4d960915a85da2ae 61a4
There's no need to write monstrosities in Perl. Just use /x:
# RegExp rules based on git-check-ref-format
my $valid_ref_name = qr%
^
(?!
# begins with
/| # (from #6) cannot begin with /
# contains
.*(?:
[/.]\.| # (from #1,3) cannot contain /. or ..
//| # (from #6) cannot contain multiple consecutive slashes
@\{| # (from #8) cannot contain a sequence @{
\\ # (from #9) cannot contain a \
)
)
# (from #2) (waiving this rule; too strict)
[^\040\177 ~^:?*[]+ # (from #4-5) valid character rules
# ends with
(? ".($branch =~ $valid_ref_name)."\n";
}
Joey++ for some of the code, though I made some corrections.