@@ -458,23 +458,26 @@ static int apply_one(
458458 }
459459
460460 /*
461- * We may be applying a second delta to an already seen file. If so,
462- * use the already modified data in the postimage instead of the
463- * content from the index or working directory. (Don't do this in
464- * the case of a rename, which must be specified before additional
465- * deltas since we apply deltas to the target filename.)
466- *
467- * Additionally, make sure that the file has not been deleted or renamed
468- * out of the way; again, except in the rename case, since we support
469- * renaming a single file into two target files.
461+ * Ensure that the file has not been deleted or renamed if we're
462+ * applying a modification delta.
470463 */
471- if (delta -> status != GIT_DELTA_RENAMED ) {
464+ if (delta -> status != GIT_DELTA_RENAMED &&
465+ delta -> status != GIT_DELTA_ADDED ) {
472466 pos = git_strmap_lookup_index (removed_paths , delta -> old_file .path );
473467 if (git_strmap_valid_index (removed_paths , pos )) {
474468 error = apply_err ("path '%s' has been renamed or deleted" , delta -> old_file .path );
475469 goto done ;
476470 }
471+ }
477472
473+ /*
474+ * We may be applying a second delta to an already seen file. If so,
475+ * use the already modified data in the postimage instead of the
476+ * content from the index or working directory. (Don't do this in
477+ * the case of a rename, which must be specified before additional
478+ * deltas since we apply deltas to the target filename.)
479+ */
480+ if (delta -> status != GIT_DELTA_RENAMED ) {
478481 if ((error = git_reader_read (& pre_contents , & pre_id , & pre_filemode ,
479482 postimage_reader , delta -> old_file .path )) == 0 ) {
480483 skip_preimage = true;
0 commit comments