Factor out make-patch into its own function to make it easier to test.