Use file handling tools to get current git branch

Instead of shelling out to git, and then munging the output, why not just check $GIT_DIR/HEAD to see what current HEAD is, if it contains / then it's a ref and we can pull a branch name out of it. Otherwise, we're not on a branch!