Skip to content

Commit 2381e39

Browse files
committed
status: --ignored option shows ignored files
There is no stronger reason behind the choice of "!!" than just I happened to have typed them. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1b908b6 commit 2381e39

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

builtin/commit.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static enum {
8383
static char *cleanup_arg;
8484

8585
static int use_editor = 1, initial_commit, in_merge, include_status = 1;
86+
static int show_ignored_in_status;
8687
static const char *only_include_assumed;
8788
static struct strbuf message;
8889

@@ -1031,6 +1032,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
10311032
"mode",
10321033
"show untracked files, optional modes: all, normal, no. (Default: all)",
10331034
PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
1035+
OPT_BOOLEAN(0, "ignored", &show_ignored_in_status,
1036+
"show ignored files"),
10341037
OPT_END(),
10351038
};
10361039

@@ -1044,7 +1047,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
10441047
builtin_status_options,
10451048
builtin_status_usage, 0);
10461049
handle_untracked_files_arg(&s);
1047-
1050+
if (show_ignored_in_status)
1051+
s.show_ignored_files = 1;
10481052
if (*argv)
10491053
s.pathspec = get_pathspec(prefix, argv);
10501054

wt-status.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,11 @@ void wt_status_print(struct wt_status *s)
646646
wt_status_print_submodule_summary(s, 0); /* staged */
647647
wt_status_print_submodule_summary(s, 1); /* unstaged */
648648
}
649-
if (s->show_untracked_files)
649+
if (s->show_untracked_files) {
650650
wt_status_print_other(s, &s->untracked, "Untracked", "add");
651-
else if (s->commitable)
651+
if (s->show_ignored_files)
652+
wt_status_print_other(s, &s->ignored, "Ignored", "add -f");
653+
} else if (s->commitable)
652654
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
653655

654656
if (s->verbose)
@@ -730,16 +732,16 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
730732
}
731733
}
732734

733-
static void wt_shortstatus_untracked(int null_termination, struct string_list_item *it,
734-
struct wt_status *s)
735+
static void wt_shortstatus_other(int null_termination, struct string_list_item *it,
736+
struct wt_status *s, const char *sign)
735737
{
736738
if (null_termination) {
737-
fprintf(stdout, "?? %s%c", it->string, 0);
739+
fprintf(stdout, "%s %s%c", sign, it->string, 0);
738740
} else {
739741
struct strbuf onebuf = STRBUF_INIT;
740742
const char *one;
741743
one = quote_path(it->string, -1, &onebuf, s->prefix);
742-
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "??");
744+
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), sign);
743745
printf(" %s\n", one);
744746
strbuf_release(&onebuf);
745747
}
@@ -763,7 +765,13 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination)
763765
struct string_list_item *it;
764766

765767
it = &(s->untracked.items[i]);
766-
wt_shortstatus_untracked(null_termination, it, s);
768+
wt_shortstatus_other(null_termination, it, s, "??");
769+
}
770+
for (i = 0; i < s->ignored.nr; i++) {
771+
struct string_list_item *it;
772+
773+
it = &(s->ignored.items[i]);
774+
wt_shortstatus_other(null_termination, it, s, "!!");
767775
}
768776
}
769777

0 commit comments

Comments
 (0)