Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
ls-files: convert prune_cache to take an index
author
Brandon Williams
<bmwill@google.com>
Mon, 12 Jun 2017 22:14:04 +0000
(15:14 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 13 Jun 2017 18:40:51 +0000
(11:40 -0700)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/ls-files.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
1d35e3b
)
diff --git
a/builtin/ls-files.c
b/builtin/ls-files.c
index 762257f3997ef91f77623bc4e1bd0fb8164d2756..b1626b13b43f3a69b35bc242c30a28b51a855306 100644
(file)
--- 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"
*/
/*
* 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;
{
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;
if (pos < 0)
pos = -pos-1;
first = pos;
- last =
activ
e_nr;
+ last =
istate->cach
e_nr;
while (last > first) {
int next = (last + first) >> 1;
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;
}
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 *));
(last - pos) * sizeof(struct cache_entry *));
-
activ
e_nr = last - pos;
+
istate->cach
e_nr = last - pos;
}
static int get_common_prefix_len(const char *common_prefix)
}
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);
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)
/* Treat unmatching pathspec elements as errors */
if (pathspec.nr && error_unmatch)