dir.c::test_one_path(): work around directory_exists_in_index_icase() breakage
directory_exists_in_index() takes pathname and its length, but its helper function directory_exists_in_index_icase() reads one byte beyond the end of the pathname and expects there to be a '/'. This needs to be fixed, as that one-byte-beyond-the-end location may not even be readable, possibly by not registering directories to name hashes with trailing slashes. In the meantime, update the new caller added recently to treat_one_path() to make sure that the path buffer it gives the function is one byte longer than the path it is asking the function about by appending a slash to it. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3c56875176
commit
680be044d9
18
dir.c
18
dir.c
@ -1202,9 +1202,21 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
|
|||||||
*/
|
*/
|
||||||
if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
|
if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
|
||||||
(dtype == DT_DIR) &&
|
(dtype == DT_DIR) &&
|
||||||
!has_path_in_index &&
|
!has_path_in_index) {
|
||||||
(directory_exists_in_index(path->buf, path->len) == index_nonexistent))
|
/*
|
||||||
return path_none;
|
* NEEDSWORK: directory_exists_in_index_icase()
|
||||||
|
* assumes that one byte past the given path is
|
||||||
|
* readable and has '/', which needs to be fixed, but
|
||||||
|
* until then, work it around in the caller.
|
||||||
|
*/
|
||||||
|
strbuf_addch(path, '/');
|
||||||
|
if (directory_exists_in_index(path->buf, path->len - 1) ==
|
||||||
|
index_nonexistent) {
|
||||||
|
strbuf_setlen(path, path->len - 1);
|
||||||
|
return path_none;
|
||||||
|
}
|
||||||
|
strbuf_setlen(path, path->len - 1);
|
||||||
|
}
|
||||||
|
|
||||||
exclude = is_excluded(dir, path->buf, &dtype);
|
exclude = is_excluded(dir, path->buf, &dtype);
|
||||||
|
|
||||||
|
@ -78,9 +78,6 @@ date >path7
|
|||||||
touch path10
|
touch path10
|
||||||
>pathx/ju/nk
|
>pathx/ju/nk
|
||||||
|
|
||||||
test_expect_success \
|
|
||||||
'git ls-files -k to show killed files.' \
|
|
||||||
'git ls-files -k >.output'
|
|
||||||
cat >.expected <<EOF
|
cat >.expected <<EOF
|
||||||
path0/file0
|
path0/file0
|
||||||
path1/file1
|
path1/file1
|
||||||
@ -89,9 +86,15 @@ path3
|
|||||||
pathx/ju/nk
|
pathx/ju/nk
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success 'git ls-files -k to show killed files (w/o icase)' '
|
||||||
'validate git ls-files -k output.' \
|
git ls-files -k >.output &&
|
||||||
'test_cmp .expected .output'
|
test_cmp .expected .output
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git ls-files -k to show killed files (w/ icase)' '
|
||||||
|
git -c core.ignorecase=true ls-files -k >.output &&
|
||||||
|
test_cmp .expected .output
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'git ls-files -m to show modified files.' \
|
'git ls-files -m to show modified files.' \
|
||||||
|
Loading…
Reference in New Issue
Block a user