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>
This commit is contained in:
parent
c33ab0dd10
commit
81a361be3b
@ -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)));
|
pos = cache_name_pos(name, ntohs(create_ce_flags(len, stage)));
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
retval = -1;
|
retval = -1;
|
||||||
if (ok_to_replace)
|
if (!ok_to_replace)
|
||||||
break;
|
break;
|
||||||
remove_cache_entry_at(pos);
|
remove_cache_entry_at(pos);
|
||||||
continue;
|
continue;
|
||||||
|
@ -272,4 +272,13 @@ test_expect_success \
|
|||||||
wc -l) &&
|
wc -l) &&
|
||||||
test $numparent = 1'
|
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
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user