[18.09 backport] gitutils: add validation for ref Upstream-commit: 200b524eff60a9c95a22bc2518042ac2ff617d07 Component: engine