Fix check_file_directory_conflict().
When replacing an existing file A with a directory A that has a file A/B in it in the index, 'update-index --replace --add A/B' did not properly remove the file to make room for the new directory. There was a trivial logic error, most likely a cut & paste one, dating back to quite early days of git. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 16, 2006 at 17:39 UTC
81a361be3b12f393d402c5da63191c11c18ea6a9
2 files changed
+10
-1
read-cache.c
+1
-1
@@ -517,7 +517,7 @@ static int has_dir_name(const struct cache_entry *ce, int pos, int ok_to_replace
517
pos = cache_name_pos(name, ntohs(create_ce_flags(len, stage)));
518
if (pos >= 0) {
519
retval = -1;
520
- if (ok_to_replace)
520
+ if (!ok_to_replace)
521
break;
522
remove_cache_entry_at(pos);
523
continue;
t/t0000-basic.sh
+9
@@ -272,4 +272,13 @@ test_expect_success \
272
wc -l) &&
273
test $numparent = 1'
274
275
+test_expect_success 'update-index D/F conflict' '
276
+ mv path0 tmp &&
277
+ mv path2 path0 &&
278
+ mv tmp path2 &&
279
+ git update-index --add --replace path2 path0/file2 &&
280
+ numpath0=$(git ls-files path0 | wc -l) &&
281
+ test $numpath0 = 1
282
+'
283
+
284
test_done