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.