From: Eric Sunshine <sunshine@sunshineco.com>
To: git@vger.kernel.org
Cc: Eric Sunshine <sunshine@sunshineco.com>,
Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Brian Gernhardt <brian@gernhardtsoftware.com>,
Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH v2 4/4] dir: revert work-around for retired dangerous behavior
Date: Tue, 17 Sep 2013 03:06:17 -0400 [thread overview]
Message-ID: <1379401577-36799-5-git-send-email-sunshine@sunshineco.com> (raw)
In-Reply-To: <1379401577-36799-1-git-send-email-sunshine@sunshineco.com>
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>
---
dir.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/dir.c b/dir.c
index fccd479..23b6de4 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);
--
1.8.4.535.g7b94f8e
next prev parent reply other threads:[~2013-09-17 7:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-17 7:06 [PATCH v2 0/4] stop storing trailing slash in dir-hash Eric Sunshine
2013-09-17 7:06 ` [PATCH v2 1/4] name-hash: refactor polymorphic index_name_exists() Eric Sunshine
2013-09-17 7:06 ` [PATCH v2 2/4] employ new explicit "exists in index?" API Eric Sunshine
2013-09-17 7:06 ` [PATCH v2 3/4] name-hash: stop storing trailing '/' on paths in index_state.dir_hash Eric Sunshine
2013-09-17 7:06 ` Eric Sunshine [this message]
2013-09-17 17:11 ` [PATCH v2 0/4] stop storing trailing slash in dir-hash Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379401577-36799-5-git-send-email-sunshine@sunshineco.com \
--to=sunshine@sunshineco.com \
--cc=brian@gernhardtsoftware.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).