]> git.ipfire.org Git - thirdparty/git.git/blobdiff - unpack-trees.c
Merge branch 'km/submodule-doc-use-sm-path' into maint
[thirdparty/git.git] / unpack-trees.c
index 2399b6818be6ddb9a6f4103cec667b2e2a9c24d0..191e738143171a08b11cfd87aac0de0246ab4d4d 100644 (file)
@@ -694,9 +694,11 @@ static int index_pos_by_traverse_info(struct name_entry *names,
        if (pos >= 0)
                BUG("This is a directory and should not exist in index");
        pos = -pos - 1;
-       if (!starts_with(o->src_index->cache[pos]->name, name.buf) ||
+       if (pos >= o->src_index->cache_nr ||
+           !starts_with(o->src_index->cache[pos]->name, name.buf) ||
            (pos > 0 && starts_with(o->src_index->cache[pos-1]->name, name.buf)))
-               BUG("pos must point at the first entry in this directory");
+               BUG("pos %d doesn't point to the first entry of %s in index",
+                   pos, name.buf);
        strbuf_release(&name);
        return pos;
 }
@@ -1305,14 +1307,14 @@ static int clear_ce_flags_dir(struct index_state *istate,
 
        if (pl->use_cone_patterns && orig_ret == MATCHED_RECURSIVE) {
                struct cache_entry **ce = cache;
-               rc = (cache_end - cache) / sizeof(struct cache_entry *);
+               rc = cache_end - cache;
 
                while (ce < cache_end) {
                        (*ce)->ce_flags &= ~clear_mask;
                        ce++;
                }
        } else if (pl->use_cone_patterns && orig_ret == NOT_MATCHED) {
-               rc = (cache_end - cache) / sizeof(struct cache_entry *);
+               rc = cache_end - cache;
        } else {
                rc = clear_ce_flags_1(istate, cache, cache_end - cache,
                                      prefix,