merge-recursive: Fix sorting order and directory change assumptions