gitweb: Move check-ref-format code into separate function