Add git_merge_bases_many.
Extract shared functionality.