format-patch: refactor branch name calculation