magit-guess-branch: fix recently introduced bug

Previously the while loop did not check for the end of the processed
list causing an error when trying to use the car of an empty list as
a string.
Merge commit '543b5db7ac0765b560d63ef136121752389dd386' into tarsius/master
Merge branch 'tarsius/master'
Merge branch 'master' into next