Skip to content

Commit 6cb3f6b

Browse files
committed
wt-status: collect ignored files
Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5b26b1 commit 6cb3f6b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

wt-status.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void wt_status_prepare(struct wt_status *s)
4242
s->index_file = get_index_file();
4343
s->change.strdup_strings = 1;
4444
s->untracked.strdup_strings = 1;
45+
s->ignored.strdup_strings = 1;
4546
}
4647

4748
static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -382,6 +383,21 @@ static void wt_status_collect_untracked(struct wt_status *s)
382383
free(ent);
383384
}
384385

386+
if (s->show_ignored_files) {
387+
dir.nr = 0;
388+
dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
389+
fill_directory(&dir, s->pathspec);
390+
for (i = 0; i < dir.nr; i++) {
391+
struct dir_entry *ent = dir.entries[i];
392+
if (!cache_name_is_other(ent->name, ent->len))
393+
continue;
394+
if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
395+
continue;
396+
string_list_insert(ent->name, &s->ignored);
397+
free(ent);
398+
}
399+
}
400+
385401
free(dir.entries);
386402
}
387403

wt-status.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct wt_status {
4141
int use_color;
4242
int relative_paths;
4343
int submodule_summary;
44+
int show_ignored_files;
4445
enum untracked_status_type show_untracked_files;
4546
char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];
4647

@@ -52,6 +53,7 @@ struct wt_status {
5253
const char *prefix;
5354
struct string_list change;
5455
struct string_list untracked;
56+
struct string_list ignored;
5557
};
5658

5759
void wt_status_prepare(struct wt_status *s);

0 commit comments

Comments
 (0)