Extracted redundant "branch spec to branch name" code
Checking for refs/heads/ in branchSpec

https://github.com/jenkinsci/git-client-plugin/pull/120/files#r10310025
comment of "dnozay"