Handle gitfiles when retrieving branch name

Move code to parse a .git file from the do_status method to a new method
shared with get_branch_name so that branch name can be retreived from
repositories which use a .git file.

Closes #634.