Improved detection of current branch when it was checked out in the wrong case