check if repo is valid and head is not detached before trying to highlight  the current branch