diff options
-rw-r--r-- | builtin/ls-files.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 762257f399..b1626b13b4 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -380,30 +380,31 @@ static void show_files(struct dir_struct *dir) /* * Prune the index to only contain stuff starting with "prefix" */ -static void prune_cache(const char *prefix, size_t prefixlen) +static void prune_index(struct index_state *istate, + const char *prefix, size_t prefixlen) { int pos; unsigned int first, last; if (!prefix) return; - pos = cache_name_pos(prefix, prefixlen); + pos = index_name_pos(istate, prefix, prefixlen); if (pos < 0) pos = -pos-1; first = pos; - last = active_nr; + last = istate->cache_nr; while (last > first) { int next = (last + first) >> 1; - const struct cache_entry *ce = active_cache[next]; + const struct cache_entry *ce = istate->cache[next]; if (!strncmp(ce->name, prefix, prefixlen)) { first = next+1; continue; } last = next; } - memmove(active_cache, active_cache + pos, + memmove(istate->cache, istate->cache + pos, (last - pos) * sizeof(struct cache_entry *)); - active_nr = last - pos; + istate->cache_nr = last - pos; } static int get_common_prefix_len(const char *common_prefix) @@ -661,7 +662,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) max_prefix = common_prefix(&pathspec); max_prefix_len = get_common_prefix_len(max_prefix); - prune_cache(max_prefix, max_prefix_len); + prune_index(&the_index, max_prefix, max_prefix_len); /* Treat unmatching pathspec elements as errors */ if (pathspec.nr && error_unmatch) |