ls-files: convert show_killed_files to take an index
Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Jun 12, 2017 at 15:14 UTC
23d6236a07be1434479a5d2f1f82cd8dda4818f9
1 file changed
+11
-10
builtin/ls-files.c
+11
-10
@@ -120,7 +120,8 @@ static void show_other_files(struct dir_struct *dir)
120
}
121
}
122
123
-static void show_killed_files(struct dir_struct *dir)
123
+static void show_killed_files(const struct index_state *istate,
124
+ const struct dir_struct *dir)
125
{
126
int i;
127
for (i = 0; i < dir->nr; i++) {
@@ -134,29 +135,29 @@ static void show_killed_files(struct dir_struct *dir)
135
/* If ent->name is prefix of an entry in the
136
* cache, it will be killed.
137
*/
137
- pos = cache_name_pos(ent->name, ent->len);
138
+ pos = index_name_pos(istate, ent->name, ent->len);
139
if (0 <= pos)
140
die("BUG: killed-file %.*s not found",
141
ent->len, ent->name);
142
pos = -pos - 1;
142
- while (pos < active_nr &&
143
- ce_stage(active_cache[pos]))
143
+ while (pos < istate->cache_nr &&
144
+ ce_stage(istate->cache[pos]))
145
pos++; /* skip unmerged */
145
- if (active_nr <= pos)
146
+ if (istate->cache_nr <= pos)
147
break;
148
/* pos points at a name immediately after
149
* ent->name in the cache. Does it expect
150
* ent->name to be a directory?
151
*/
151
- len = ce_namelen(active_cache[pos]);
152
+ len = ce_namelen(istate->cache[pos]);
153
if ((ent->len < len) &&
153
- !strncmp(active_cache[pos]->name,
154
+ !strncmp(istate->cache[pos]->name,
155
ent->name, ent->len) &&
155
- active_cache[pos]->name[ent->len] == '/')
156
+ istate->cache[pos]->name[ent->len] == '/')
157
killed = 1;
158
break;
159
}
159
- if (0 <= cache_name_pos(ent->name, sp - ent->name)) {
160
+ if (0 <= index_name_pos(istate, ent->name, sp - ent->name)) {
161
/* If any of the leading directories in
162
* ent->name is registered in the cache,
163
* ent->name will be killed.
@@ -337,7 +338,7 @@ static void show_files(struct dir_struct *dir)
338
if (show_others)
339
show_other_files(dir);
340
if (show_killed)
340
- show_killed_files(dir);
341
+ show_killed_files(&the_index, dir);
342
}
343
if (show_cached || show_stage) {
344
for (i = 0; i < active_nr; i++) {