Skip to content

Commit bc6bb8d

Browse files
jamilldscho
authored andcommitted
Merge pull request #70 from jamill/jamill/virtual_filesystem_directories
virtualfilesystem: fix case where directories not handled correctly
2 parents eaed3e8 + a0fb60f commit bc6bb8d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

t/t1092-virtualfilesystem.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,23 @@ test_expect_success 'on folder renamed' '
348348
test_cmp expected actual
349349
'
350350

351+
test_expect_success 'folder with same prefix as file' '
352+
clean_repo &&
353+
touch dir1.sln &&
354+
write_script .git/hooks/virtualfilesystem <<-\EOF &&
355+
printf "dir1/\0"
356+
printf "dir1.sln\0"
357+
EOF
358+
git add dir1.sln &&
359+
git ls-files -v > actual &&
360+
cat > expected <<-\EOF &&
361+
H dir1.sln
362+
H dir1/file1.txt
363+
H dir1/file2.txt
364+
S dir2/file1.txt
365+
S dir2/file2.txt
366+
EOF
367+
test_cmp expected actual
368+
'
369+
351370
test_done

virtualfilesystem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void apply_virtualfilesystem(struct index_state *istate)
273273
if (buf[i - 1] == '/') {
274274
if (ignore_case)
275275
adjust_dirname_case(istate, entry);
276-
pos = index_name_pos(istate, entry, len - 1);
276+
pos = index_name_pos(istate, entry, len);
277277
if (pos < 0) {
278278
pos = -pos - 1;
279279
while (pos < istate->cache_nr && !fspathncmp(istate->cache[pos]->name, entry, len)) {

0 commit comments

Comments
 (0)