branch: factor out check_branch_commit()