diff --git a/read-cache.c b/read-cache.c
index 983e68b892a9922e8d46c83a5a39b36d535d95dd..b8d83ccd9f7985d60f69b7cd44db698d4e932612 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
@@ -517,7 +517,7 @@ static int has_dir_name(const struct cache_entry *ce, int pos, int ok_to_replace
pos = cache_name_pos(name, ntohs(create_ce_flags(len, stage)));
if (pos >= 0) {
retval = -1;
- if (ok_to_replace)
+ if (!ok_to_replace)
break;
remove_cache_entry_at(pos);
continue;