git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Clemens Buchacher <drizzd@aon.at>
Subject: [PATCH 3/3] unpack-trees: remove redundant path search in verify_absent
Date: Thu,  1 Jan 2009 21:54:33 +0100	[thread overview]
Message-ID: <1230843273-11056-4-git-send-email-drizzd@aon.at> (raw)
In-Reply-To: <1230843273-11056-3-git-send-email-drizzd@aon.at>

Since the only caller, verify_absent, relies on the fact that o->pos
points to the next index entry anyways, there is no need to recompute
its position.

Furthermore, if a nondirectory entry were found, this would return too
early, because there could still be an untracked directory in the way.
This is currently not a problem, because verify_absent is only called
if the index does not have this entry.
---
 unpack-trees.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index f8e2484..c4dc6dc 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -495,7 +495,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
 	 * anything in the existing directory there.
 	 */
 	int namelen;
-	int pos, i;
+	int i;
 	struct dir_struct d;
 	char *pathbuf;
 	int cnt = 0;
@@ -516,11 +516,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
 	 * in that directory.
 	 */
 	namelen = strlen(ce->name);
-	pos = index_name_pos(o->src_index, ce->name, namelen);
-	if (0 <= pos)
-		return 0; /* we have it as nondirectory */
-	pos = -pos - 1;
-	for (i = pos; i < o->src_index->cache_nr; i++) {
+	for (i = o->pos; i < o->src_index->cache_nr; i++) {
 		struct cache_entry *ce2 = o->src_index->cache[i];
 		int len = ce_namelen(ce2);
 		if (len < namelen ||
-- 
1.6.1

  reply	other threads:[~2009-01-01 21:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-01 20:54 unpack-trees: fix D/F conflict bugs in verify_absent Clemens Buchacher
2009-01-01 20:54 ` [PATCH 1/3] unpack-trees: handle failure " Clemens Buchacher
2009-01-01 20:54   ` [PATCH 2/3] unpack-trees: fix path search bug " Clemens Buchacher
2009-01-01 20:54     ` Clemens Buchacher [this message]
2009-01-06  8:19       ` [PATCH 3/3] unpack-trees: remove redundant path search " Junio C Hamano
2009-01-02 21:59     ` [PATCH 2/3] unpack-trees: fix path search bug " Johannes Schindelin
2009-01-03 10:39       ` Clemens Buchacher
2009-01-03 12:53         ` Johannes Schindelin
2009-01-04 10:01           ` Junio C Hamano
2009-01-04 20:01             ` Clemens Buchacher
2009-01-06 19:35               ` Johannes Schindelin
2011-01-13  2:24   ` [RFC/PATCH 0/2] unpack-trees: handle lstat failures " Jonathan Nieder
2011-01-13  2:26     ` [PATCH 1/2] unpack-trees: handle lstat failure for existing directory Jonathan Nieder
2011-01-13  4:37       ` Miles Bader
2011-01-13  5:38         ` Jonathan Nieder
2011-01-13  2:28     ` [PATCH 2/2] unpack-trees: handle lstat failure for existing file Jonathan Nieder
2011-01-13 20:20     ` [RFC/PATCH 0/2] unpack-trees: handle lstat failures in verify_absent Clemens Buchacher
2009-01-01 21:28 ` unpack-trees: fix D/F conflict bugs " Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2008-12-16 23:24 Strange untracked file behaviour Miklos Vajna
2008-12-17  5:09 ` Johannes Schindelin
2008-12-17 14:38   ` Miklos Vajna
2009-01-02 21:59 ` [PATCH 2/3] unpack-trees: fix path search bug in verify_absent Johannes Schindelin
2009-01-03 14:01   ` Miklos Vajna

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=1230843273-11056-4-git-send-email-drizzd@aon.at \
    --to=drizzd@aon.at \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).