ls-files: convert show_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
f587c8dcdef17aea15aee45689e181b58b011706
1 file changed
+15
-15
builtin/ls-files.c
+15
-15
@@ -329,7 +329,7 @@ static int ce_excluded(struct dir_struct *dir, struct index_state *istate,
329
return is_excluded(dir, istate, ce->name, &dtype);
330
}
331
332
-static void show_files(struct dir_struct *dir)
332
+static void show_files(struct index_state *istate, struct dir_struct *dir)
333
{
334
int i;
335
@@ -337,33 +337,33 @@ static void show_files(struct dir_struct *dir)
337
if (show_others || show_killed) {
338
if (!show_others)
339
dir->flags |= DIR_COLLECT_KILLED_ONLY;
340
- fill_directory(dir, &the_index, &pathspec);
340
+ fill_directory(dir, istate, &pathspec);
341
if (show_others)
342
- show_other_files(&the_index, dir);
342
+ show_other_files(istate, dir);
343
if (show_killed)
344
- show_killed_files(&the_index, dir);
344
+ show_killed_files(istate, dir);
345
}
346
if (show_cached || show_stage) {
347
- for (i = 0; i < active_nr; i++) {
348
- const struct cache_entry *ce = active_cache[i];
347
+ for (i = 0; i < istate->cache_nr; i++) {
348
+ const struct cache_entry *ce = istate->cache[i];
349
if ((dir->flags & DIR_SHOW_IGNORED) &&
350
- !ce_excluded(dir, &the_index, ce))
350
+ !ce_excluded(dir, istate, ce))
351
continue;
352
if (show_unmerged && !ce_stage(ce))
353
continue;
354
if (ce->ce_flags & CE_UPDATE)
355
continue;
356
- show_ce_entry(&the_index, ce_stage(ce) ? tag_unmerged :
356
+ show_ce_entry(istate, ce_stage(ce) ? tag_unmerged :
357
(ce_skip_worktree(ce) ? tag_skip_worktree : tag_cached), ce);
358
}
359
}
360
if (show_deleted || show_modified) {
361
- for (i = 0; i < active_nr; i++) {
362
- const struct cache_entry *ce = active_cache[i];
361
+ for (i = 0; i < istate->cache_nr; i++) {
362
+ const struct cache_entry *ce = istate->cache[i];
363
struct stat st;
364
int err;
365
if ((dir->flags & DIR_SHOW_IGNORED) &&
366
- !ce_excluded(dir, &the_index, ce))
366
+ !ce_excluded(dir, istate, ce))
367
continue;
368
if (ce->ce_flags & CE_UPDATE)
369
continue;
@@ -371,9 +371,9 @@ static void show_files(struct dir_struct *dir)
371
continue;
372
err = lstat(ce->name, &st);
373
if (show_deleted && err)
374
- show_ce_entry(&the_index, tag_removed, ce);
375
- if (show_modified && ce_modified(ce, &st, 0))
376
- show_ce_entry(&the_index, tag_modified, ce);
374
+ show_ce_entry(istate, tag_removed, ce);
375
+ if (show_modified && ie_modified(istate, ce, &st, 0))
376
+ show_ce_entry(istate, tag_modified, ce);
377
}
378
}
379
}
@@ -686,7 +686,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
686
die("ls-files --with-tree is incompatible with -s or -u");
687
overlay_tree_on_index(&the_index, with_tree, max_prefix);
688
}
689
- show_files(&dir);
689
+ show_files(&the_index, &dir);
690
if (show_resolve_undo)
691
show_ru_info(&the_index);
692