[PATCH 3/3] unpack-trees: remove redundant path search in verify_absent

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Clemens Buchacher
Date: Thursday, January 1, 2009 - 1:54 pm

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
unpack-trees: fix D/F conflict bugs in verify_absent, Clemens Buchacher, (Thu Jan 1, 1:54 pm)
[PATCH 1/3] unpack-trees: handle failure in verify_absent, Clemens Buchacher, (Thu Jan 1, 1:54 pm)
[PATCH 3/3] unpack-trees: remove redundant path search in ..., Clemens Buchacher, (Thu Jan 1, 1:54 pm)
Re: unpack-trees: fix D/F conflict bugs in verify_absent, Junio C Hamano, (Thu Jan 1, 2:28 pm)
Re: [PATCH 2/3] unpack-trees: fix path search bug in verif ..., Johannes Schindelin, (Fri Jan 2, 2:59 pm)
Re: [PATCH 2/3] unpack-trees: fix path search bug in verif ..., Johannes Schindelin, (Fri Jan 2, 2:59 pm)
Re: [PATCH 2/3] unpack-trees: fix path search bug in verif ..., Johannes Schindelin, (Sat Jan 3, 5:53 am)