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 nil as a string.