Merge branch 'pw/sequence-rerere-autoupdate' into next
[gitweb.git] / builtin / ls-files.c
index b8514a0029a1437687a5cf6b6f8bad9792340bc3..c6126eae550beb75e7c90094be337efbb48cd3bc 100644 (file)
@@ -362,7 +362,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)
@@ -378,8 +378,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;
 }