fast-export: ensure that a renamed file is printed after all references
[gitweb.git] / fast-import.c
index 309f2c58a2ba431a82a56f757482a5093cc8257d..75ed738b7c2847099df2ddb42b0d2d3c7dc70cbe 100644 (file)
@@ -1528,6 +1528,14 @@ static int tree_content_remove(
        for (i = 0; i < t->entry_count; i++) {
                e = t->entries[i];
                if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
+                       if (slash1 && !S_ISDIR(e->versions[1].mode))
+                               /*
+                                * If p names a file in some subdirectory, and a
+                                * file or symlink matching the name of the
+                                * parent directory of p exists, then p cannot
+                                * exist and need not be deleted.
+                                */
+                               return 1;
                        if (!slash1 || !S_ISDIR(e->versions[1].mode))
                                goto del_entry;
                        if (!e->tree)