aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--read-cache.c2
-rwxr-xr-xt/t0000-basic.sh9
2 files changed, 10 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c
index 983e68b89..b8d83ccd9 100644
--- 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;
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 3260d1d7a..0cd1c4186 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -272,4 +272,13 @@ test_expect_success \
wc -l) &&
test $numparent = 1'
+test_expect_success 'update-index D/F conflict' '
+ mv path0 tmp &&
+ mv path2 path0 &&
+ mv tmp path2 &&
+ git update-index --add --replace path2 path0/file2 &&
+ numpath0=$(git ls-files path0 | wc -l) &&
+ test $numpath0 = 1
+'
+
test_done