Merge branch 'bw/submodule-config-cleanup'
[gitweb.git] / builtin / ls-files.c
index bd74ee07db4182801bd26f0a6f931882f0b310bc..e1339e6d17d2bf592b800d3e5a686cbc91c12331 100644 (file)
@@ -361,7 +361,7 @@ static void prune_index(struct index_state *istate,
        int pos;
        unsigned int first, last;
 
-       if (!prefix)
+       if (!prefix || !istate->cache_nr)
                return;
        pos = index_name_pos(istate, prefix, prefixlen);
        if (pos < 0)
@@ -377,8 +377,7 @@ static void prune_index(struct index_state *istate,
                }
                last = next;
        }
-       memmove(istate->cache, istate->cache + pos,
-               (last - pos) * sizeof(struct cache_entry *));
+       MOVE_ARRAY(istate->cache, istate->cache + pos, last - pos);
        istate->cache_nr = last - pos;
 }