Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtualfilesystem: fix case where directories not handled correctly #70

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions t/t1092-virtualfilesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,23 @@ test_expect_success 'on folder renamed' '
test_cmp expected actual
'

test_expect_success 'folder with same prefix as file' '
clean_repo &&
touch dir1.sln &&
write_script .git/hooks/virtualfilesystem <<-\EOF &&
printf "dir1/\0"
printf "dir1.sln\0"
EOF
git add dir1.sln &&
git ls-files -v > actual &&
cat > expected <<-\EOF &&
H dir1.sln
H dir1/file1.txt
H dir1/file2.txt
S dir2/file1.txt
S dir2/file2.txt
EOF
test_cmp expected actual
'

test_done
2 changes: 1 addition & 1 deletion virtualfilesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void apply_virtualfilesystem(struct index_state *istate)
if (buf[i - 1] == '/') {
if (ignore_case)
adjust_dirname_case(istate, entry);
pos = index_name_pos(istate, entry, len - 1);
pos = index_name_pos(istate, entry, len);
if (pos < 0) {
pos = -pos - 1;
while (pos < istate->cache_nr && !fspathncmp(istate->cache[pos]->name, entry, len)) {
Expand Down