aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2013-09-17 03:06:17 -0400
committerJunio C Hamano <gitster@pobox.com>2013-09-17 10:08:27 -0700
commitde372b1b46d91ffdcd6eb6e324cb8b586c99c539 (patch)
treecc5537b3d019eae8856d7f5852e3b637ebd624ab
parentd28eec267374c476de490bff736a627da94575c5 (diff)
downloadgit-de372b1b46d91ffdcd6eb6e324cb8b586c99c539.tar.gz
git-de372b1b46d91ffdcd6eb6e324cb8b586c99c539.tar.xz
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 '/'. 2eac2a4c (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 680be044 (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 <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--dir.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/dir.c b/dir.c
index fccd47955..23b6de470 100644
--- a/dir.c
+++ b/dir.c
@@ -1160,21 +1160,9 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
*/
if ((dir->flags & DIR_COLLECT_KILLED_ONLY) &&
(dtype == DT_DIR) &&
- !has_path_in_index) {
- /*
- * 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);
- }
+ !has_path_in_index &&
+ (directory_exists_in_index(path->buf, path->len) == index_nonexistent))
+ return path_none;
exclude = is_excluded(dir, path->buf, &dtype);