Skip to content

Commit 4cba2b0

Browse files
newrengitster
authored andcommitted
merge-recursive: ignore_case shouldn't reject intentional removals
In commit ae352c7 (merge-recursive.c: fix case-changing merge bug, 2014-05-01), it was observed that removing files could be problematic on case insensitive file systems, because we could end up removing files that differed in case only rather than deleting the intended file -- something that happened when files were renamed on one branch in a way that differed only in case. To avoid that problem, that commit added logic to avoid removing files other than the one intended, rejecting the removal if the files differed only in case. Unfortunately, the logic it used didn't fully implement that condition as stated above; instead it merely checked that a case-insensitive lookup of the file that was requested resulted in finding a file in the index at stage 0, not that the file found in the index actually differed in case. Alternatively, one could view the implementation as making an implicit assumption that the file we actually wanted to remove would never appear in the index with a stage of 0, and thus that if we found a file with our lookup, that it had to be a different file (but different in case only). The net result of this implementation is that it can ignore more requests than it should, leaving a file around in the working copy that should have been removed. Make sure that the file found in the index actually differs in case before silently ignoring the request to remove the file. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7d22aec commit 4cba2b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static int remove_file(struct merge_options *o, int clean,
646646
if (ignore_case) {
647647
struct cache_entry *ce;
648648
ce = cache_file_exists(path, strlen(path), ignore_case);
649-
if (ce && ce_stage(ce) == 0)
649+
if (ce && ce_stage(ce) == 0 && strcmp(path, ce->name))
650650
return 0;
651651
}
652652
if (remove_path(path))

0 commit comments

Comments
 (0)