commit: convert commit_graft_pos() to handle arbitrary repositories