@matheusbsbs / matheus-bagliano / commits / 6c2ce048bb
Fork 0

Add argument 'no' commit/status option -u|--untracked-files

This new argument teaches Git to not look for any untracked files, saving cycles on slow file systems, or large repos. Signed-off-by: Marius Storm-Olsen <marius@trolltech.com>

Marius Storm-Olsen committed Jun 5, 2008 at 14:22 UTC 6c2ce048bbfc6fbc2bdd86a3e586cb8881eb2dc2
5 files changed +34 -6
Documentation/git-commit.txt
+1
@@ -157,6 +157,7 @@ The mode parameter is optional, and is used to specify
157 the handling of untracked files. The possible options are:
158 +
159 --
160 + - 'no' - Show no untracked files
161 - 'normal' - Shows untracked files and directories
162 - 'all' - Also shows individual files in untracked directories.
163 --
builtin-commit.c
+3 -1
@@ -103,7 +103,7 @@ static struct option builtin_commit_options[] = {
103 OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
104 OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
105 OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
106 - { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
106 + { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
107 OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
108 OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
109
@@ -798,6 +798,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
798
799 if (!untracked_files_arg)
800 ; /* default already initialized */
801 + else if (!strcmp(untracked_files_arg, "no"))
802 + show_untracked_files = SHOW_NO_UNTRACKED_FILES;
803 else if (!strcmp(untracked_files_arg, "normal"))
804 show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
805 else if (!strcmp(untracked_files_arg, "all"))
t/t7502-status.sh
+22 -3
@@ -67,6 +67,28 @@ test_expect_success 'status (2)' '
67
68 '
69
70 +cat >expect <<EOF
71 +# On branch master
72 +# Changes to be committed:
73 +# (use "git reset HEAD <file>..." to unstage)
74 +#
75 +# new file: dir2/added
76 +#
77 +# Changed but not updated:
78 +# (use "git add <file>..." to update what will be committed)
79 +#
80 +# modified: dir1/modified
81 +#
82 +# Untracked files not listed (use -u option to show untracked files)
83 +EOF
84 +test_expect_success 'status -uno' '
85 + mkdir dir3 &&
86 + : > dir3/untracked1 &&
87 + : > dir3/untracked2 &&
88 + git status -uno >output &&
89 + test_cmp expect output
90 +'
91 +
92 cat >expect <<EOF
93 # On branch master
94 # Changes to be committed:
@@ -91,9 +113,6 @@ cat >expect <<EOF
113 # untracked
114 EOF
115 test_expect_success 'status -unormal' '
94 - mkdir dir3 &&
95 - : > dir3/untracked1 &&
96 - : > dir3/untracked2 &&
116 git status -unormal >output &&
117 test_cmp expect output
118 '
wt-status.c
+6 -1
@@ -348,7 +348,10 @@ void wt_status_print(struct wt_status *s)
348 wt_status_print_changed(s);
349 if (wt_status_submodule_summary)
350 wt_status_print_submodule_summary(s);
351 - wt_status_print_untracked(s);
351 + if (show_untracked_files)
352 + wt_status_print_untracked(s);
353 + else if (s->commitable)
354 + fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
355
356 if (s->verbose && !s->is_initial)
357 wt_status_print_verbose(s);
@@ -363,6 +366,8 @@ void wt_status_print(struct wt_status *s)
366 printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
367 else if (s->is_initial)
368 printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
369 + else if (!show_untracked_files)
370 + printf("nothing to commit (use -u to show untracked files)\n");
371 else
372 printf("nothing to commit (working directory clean)\n");
373 }
wt-status.h
+2 -1
@@ -12,7 +12,8 @@ enum color_wt_status {
12 };
13
14 enum untracked_status_type {
15 - SHOW_NORMAL_UNTRACKED_FILES = 1,
15 + SHOW_NO_UNTRACKED_FILES,
16 + SHOW_NORMAL_UNTRACKED_FILES,
17 SHOW_ALL_UNTRACKED_FILES
18 };
19 extern enum untracked_status_type show_untracked_files;