Skip to content

Commit de372b1

Browse files
sunshinecogitster
authored andcommitted
dir: revert work-around for retired dangerous behavior
directory_exists_in_index_icase() dangerously assumed that it could access one character beyond the end of its directory argument, and that that character would unconditionally be '/'. 2eac2a4 (ls-files -k: a directory only can be killed if the index has a non-directory, 2013-08-15) added a caller which did not respect this undocumented assumption, and 680be04 (dir.c::test_one_path(): work around directory_exists_in_index_icase() breakage, 2013-08-23) added a work-around which temporarily appends a '/' before invoking directory_exists_in_index_icase(). Since the dangerous behavior of directory_exists_in_index_icase() has been eliminated, the work-around is now redundant, so retire it (but not the tests added by the same commit). Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d28eec2 commit de372b1

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

dir.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,21 +1160,9 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
11601160
*/
11611161
if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
11621162
(dtype == DT_DIR) &&
1163-
!has_path_in_index) {
1164-
/*
1165-
* NEEDSWORK: directory_exists_in_index_icase()
1166-
* assumes that one byte past the given path is
1167-
* readable and has '/', which needs to be fixed, but
1168-
* until then, work it around in the caller.
1169-
*/
1170-
strbuf_addch(path, '/');
1171-
if (directory_exists_in_index(path->buf, path->len - 1) ==
1172-
index_nonexistent) {
1173-
strbuf_setlen(path, path->len - 1);
1174-
return path_none;
1175-
}
1176-
strbuf_setlen(path, path->len - 1);
1177-
}
1163+
!has_path_in_index &&
1164+
(directory_exists_in_index(path->buf, path->len) == index_nonexistent))
1165+
return path_none;
11781166

11791167
exclude = is_excluded(dir, path->buf, &dtype);
11801168

0 commit comments

Comments
 (0)