Merge pull request #183 from thaJeztah/18.09_backport_gitutils

[18.09 backport] gitutils: add validation for ref