commit: avoid race when creating orphan commits