@matheusbsbs / matheus-bagliano / commits / 2381e39e5f
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Apr 10, 2010 at 00:33 UTC 2381e39e5ff740883b98c5aca019950f9167b67f
2 files changed +20 -8
builtin/commit.c
+5 -1
@@ -83,6 +83,7 @@ static enum {
83 static char *cleanup_arg;
84
85 static int use_editor = 1, initial_commit, in_merge, include_status = 1;
86 +static int show_ignored_in_status;
87 static const char *only_include_assumed;
88 static struct strbuf message;
89
@@ -1031,6 +1032,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1032 "mode",
1033 "show untracked files, optional modes: all, normal, no. (Default: all)",
1034 PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
1035 + OPT_BOOLEAN(0, "ignored", &show_ignored_in_status,
1036 + "show ignored files"),
1037 OPT_END(),
1038 };
1039
@@ -1044,7 +1047,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1047 builtin_status_options,
1048 builtin_status_usage, 0);
1049 handle_untracked_files_arg(&s);
1047 -
1050 + if (show_ignored_in_status)
1051 + s.show_ignored_files = 1;
1052 if (*argv)
1053 s.pathspec = get_pathspec(prefix, argv);
1054
wt-status.c
+15 -7
@@ -646,9 +646,11 @@ void wt_status_print(struct wt_status *s)
646 wt_status_print_submodule_summary(s, 0); /* staged */
647 wt_status_print_submodule_summary(s, 1); /* unstaged */
648 }
649 - if (s->show_untracked_files)
649 + if (s->show_untracked_files) {
650 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)
654 fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
655
656 if (s->verbose)
@@ -730,16 +732,16 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
732 }
733 }
734
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)
737 {
738 if (null_termination) {
737 - fprintf(stdout, "?? %s%c", it->string, 0);
739 + fprintf(stdout, "%s %s%c", sign, it->string, 0);
740 } else {
741 struct strbuf onebuf = STRBUF_INIT;
742 const char *one;
743 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);
745 printf(" %s\n", one);
746 strbuf_release(&onebuf);
747 }
@@ -763,7 +765,13 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination)
765 struct string_list_item *it;
766
767 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, "!!");
775 }
776 }
777