summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2013-08-23 23:26:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-08-23 23:26:59 (GMT)
commit680be044d98b3b703bc33d546a987c19b3779aeb (patch)
treef9387cfa9f21d5d237be3b151dc18b1504a7d27e /dir.c
parent3c56875176390eee7d81795294124ce90189d876 (diff)
downloadgit-680be044d98b3b703bc33d546a987c19b3779aeb.zip
git-680be044d98b3b703bc33d546a987c19b3779aeb.tar.gz
git-680be044d98b3b703bc33d546a987c19b3779aeb.tar.bz2
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>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/dir.c b/dir.c
index ff768f3..1000dc2 100644
--- a/dir.c
+++ b/dir.c
@@ -1202,9 +1202,21 @@ 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 &&
- (directory_exists_in_index(path->buf, path->len) == index_nonexistent))
- return path_none;
+ !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);
+ }
exclude = is_excluded(dir, path->buf, &dtype);