Skip to content

Commit 7b9e3ce

Browse files
Clemens Buchachergitster
authored andcommitted
unpack-trees: remove redundant path search in verify_absent
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. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 837e5fe commit 7b9e3ce

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

unpack-trees.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
493493
* anything in the existing directory there.
494494
*/
495495
int namelen;
496-
int pos, i;
496+
int i;
497497
struct dir_struct d;
498498
char *pathbuf;
499499
int cnt = 0;
@@ -514,11 +514,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
514514
* in that directory.
515515
*/
516516
namelen = strlen(ce->name);
517-
pos = index_name_pos(o->src_index, ce->name, namelen);
518-
if (0 <= pos)
519-
return 0; /* we have it as nondirectory */
520-
pos = -pos - 1;
521-
for (i = pos; i < o->src_index->cache_nr; i++) {
517+
for (i = o->pos; i < o->src_index->cache_nr; i++) {
522518
struct cache_entry *ce2 = o->src_index->cache[i];
523519
int len = ce_namelen(ce2);
524520
if (len < namelen ||

0 commit comments

Comments
 (0)