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>
This commit is contained in:
parent
4bfee30a98
commit
6c2ce048bb
@ -157,6 +157,7 @@ The mode parameter is optional, and is used to specify
|
|||||||
the handling of untracked files. The possible options are:
|
the handling of untracked files. The possible options are:
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
|
- 'no' - Show no untracked files
|
||||||
- 'normal' - Shows untracked files and directories
|
- 'normal' - Shows untracked files and directories
|
||||||
- 'all' - Also shows individual files in untracked directories.
|
- 'all' - Also shows individual files in untracked directories.
|
||||||
--
|
--
|
||||||
|
@ -103,7 +103,7 @@ static struct option builtin_commit_options[] = {
|
|||||||
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
|
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
|
||||||
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
|
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
|
||||||
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
|
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
|
||||||
{ 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" },
|
{ 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" },
|
||||||
OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
|
OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
|
||||||
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
|
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
|
||||||
|
|
||||||
@ -798,6 +798,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
|||||||
|
|
||||||
if (!untracked_files_arg)
|
if (!untracked_files_arg)
|
||||||
; /* default already initialized */
|
; /* default already initialized */
|
||||||
|
else if (!strcmp(untracked_files_arg, "no"))
|
||||||
|
show_untracked_files = SHOW_NO_UNTRACKED_FILES;
|
||||||
else if (!strcmp(untracked_files_arg, "normal"))
|
else if (!strcmp(untracked_files_arg, "normal"))
|
||||||
show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
|
show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
|
||||||
else if (!strcmp(untracked_files_arg, "all"))
|
else if (!strcmp(untracked_files_arg, "all"))
|
||||||
|
@ -67,6 +67,28 @@ test_expect_success 'status (2)' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat >expect <<EOF
|
||||||
|
# On branch master
|
||||||
|
# Changes to be committed:
|
||||||
|
# (use "git reset HEAD <file>..." to unstage)
|
||||||
|
#
|
||||||
|
# new file: dir2/added
|
||||||
|
#
|
||||||
|
# Changed but not updated:
|
||||||
|
# (use "git add <file>..." to update what will be committed)
|
||||||
|
#
|
||||||
|
# modified: dir1/modified
|
||||||
|
#
|
||||||
|
# Untracked files not listed (use -u option to show untracked files)
|
||||||
|
EOF
|
||||||
|
test_expect_success 'status -uno' '
|
||||||
|
mkdir dir3 &&
|
||||||
|
: > dir3/untracked1 &&
|
||||||
|
: > dir3/untracked2 &&
|
||||||
|
git status -uno >output &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
|
||||||
cat >expect <<EOF
|
cat >expect <<EOF
|
||||||
# On branch master
|
# On branch master
|
||||||
# Changes to be committed:
|
# Changes to be committed:
|
||||||
@ -91,9 +113,6 @@ cat >expect <<EOF
|
|||||||
# untracked
|
# untracked
|
||||||
EOF
|
EOF
|
||||||
test_expect_success 'status -unormal' '
|
test_expect_success 'status -unormal' '
|
||||||
mkdir dir3 &&
|
|
||||||
: > dir3/untracked1 &&
|
|
||||||
: > dir3/untracked2 &&
|
|
||||||
git status -unormal >output &&
|
git status -unormal >output &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
@ -348,7 +348,10 @@ void wt_status_print(struct wt_status *s)
|
|||||||
wt_status_print_changed(s);
|
wt_status_print_changed(s);
|
||||||
if (wt_status_submodule_summary)
|
if (wt_status_submodule_summary)
|
||||||
wt_status_print_submodule_summary(s);
|
wt_status_print_submodule_summary(s);
|
||||||
wt_status_print_untracked(s);
|
if (show_untracked_files)
|
||||||
|
wt_status_print_untracked(s);
|
||||||
|
else if (s->commitable)
|
||||||
|
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
|
||||||
|
|
||||||
if (s->verbose && !s->is_initial)
|
if (s->verbose && !s->is_initial)
|
||||||
wt_status_print_verbose(s);
|
wt_status_print_verbose(s);
|
||||||
@ -363,6 +366,8 @@ void wt_status_print(struct wt_status *s)
|
|||||||
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
|
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
|
||||||
else if (s->is_initial)
|
else if (s->is_initial)
|
||||||
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
|
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
|
||||||
|
else if (!show_untracked_files)
|
||||||
|
printf("nothing to commit (use -u to show untracked files)\n");
|
||||||
else
|
else
|
||||||
printf("nothing to commit (working directory clean)\n");
|
printf("nothing to commit (working directory clean)\n");
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ enum color_wt_status {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum untracked_status_type {
|
enum untracked_status_type {
|
||||||
SHOW_NORMAL_UNTRACKED_FILES = 1,
|
SHOW_NO_UNTRACKED_FILES,
|
||||||
|
SHOW_NORMAL_UNTRACKED_FILES,
|
||||||
SHOW_ALL_UNTRACKED_FILES
|
SHOW_ALL_UNTRACKED_FILES
|
||||||
};
|
};
|
||||||
extern enum untracked_status_type show_untracked_files;
|
extern enum untracked_status_type show_untracked_files;
|
||||||
|
Loading…
Reference in New Issue
Block a user