699
/*
700
* Although dir_rename_count was passed in
701
* diffcore_rename_extended() and we want to keep it around and
702
- * return it to that caller, we first want to remove any data
702
+ * return it to that caller, we first want to remove any counts in
703
+ * the maps associated with UNKNOWN_DIR entries and any data
704
* associated with directories that weren't renamed.
705
*/
706
strmap_for_each_entry(info->dir_rename_count, &iter, entry) {
712
strintmap_clear(counts);
713
continue;
714
}
715
+
716
+ if (strintmap_contains(counts, UNKNOWN_DIR))
717
+ strintmap_remove(counts, UNKNOWN_DIR);
718
}
719
for (i = 0; i < to_remove.nr; ++i)
720
strmap_remove(info->dir_rename_count,
1129
* a majority.
1130
*/
1131
1132
+ int i;
1133
struct hashmap_iter iter;
1134
struct strmap_entry *entry;
1135
1139
return; /* culling incompatbile with break detection */
1140
1141
/*
1137
- * FIXME: Supplement dir_rename_count with number of potential
1138
- * renames, marking all potential rename sources as mapping to
1139
- * UNKNOWN_DIR.
1142
+ * Supplement dir_rename_count with number of potential renames,
1143
+ * marking all potential rename sources as mapping to UNKNOWN_DIR.
1144
*/
1145
+ for (i = 0; i < rename_src_nr; i++) {
1146
+ char *old_dir;
1147
+ struct diff_filespec *one = rename_src[i].p->one;
1148
+
1149
+ /*
1150
+ * sources that are part of a rename will have already been
1151
+ * removed by a prior call to remove_unneeded_paths_from_src()
1152
+ */
1153
+ assert(!one->rename_used);
1154
+
1155
+ old_dir = get_dirname(one->path);
1156
+ while (*old_dir != '\0' &&
1157
+ NOT_RELEVANT != strintmap_get(dirs_removed, old_dir)) {
1158
+ char *freeme = old_dir;
1159
+
1160
+ increment_count(info, old_dir, UNKNOWN_DIR);
1161
+ old_dir = get_dirname(old_dir);
1162
+
1163
+ /* Free resources we don't need anymore */
1164
+ free(freeme);
1165
+ }
1166
+ /*
1167
+ * old_dir and new_dir free'd in increment_count, but
1168
+ * get_dirname() gives us a new pointer we need to free for
1169
+ * old_dir. Also, if the loop runs 0 times we need old_dir
1170
+ * to be freed.
1171
+ */
1172
+ free(old_dir);
1173
+ }
1174
1175
/*
1176
* For any directory which we need a potential rename detected for