From: Marius Storm-Olsen <marius@trolltech.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>
Subject: [PATCH 2/3] Add argument 'no' commit/status option -u|--untracked-files
Date: Thu, 5 Jun 2008 14:22:56 +0200 [thread overview]
Message-ID: <f6ce4457c92b77210ceceeddb32cf30ca65103ed.1212995703.git.marius@trolltech.com> (raw)
In-Reply-To: c756e040b06883cc070bb24954111b4dcd457d2c.1212995703.git.marius@trolltech.com
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>
---
Documentation/git-commit.txt | 1 +
builtin-commit.c | 4 +++-
t/t7502-status.sh | 25 ++++++++++++++++++++++---
wt-status.c | 7 ++++++-
wt-status.h | 3 ++-
5 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index cc4374a..a6db831 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -157,6 +157,7 @@ The mode parameter is optional, and is used to specify
the handling of untracked files. The possible options are:
+
--
+ - 'no' - Show no untracked files
- 'normal' - Shows untracked files and directories
- 'all' - Also shows individual files in untracked directories.
--
diff --git a/builtin-commit.c b/builtin-commit.c
index 95cdb82..f3e524a 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -103,7 +103,7 @@ static struct option builtin_commit_options[] = {
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
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_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)
; /* default already initialized */
+ else if (!strcmp(untracked_files_arg, "no"))
+ show_untracked_files = SHOW_NO_UNTRACKED_FILES;
else if (!strcmp(untracked_files_arg, "normal"))
show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
else if (!strcmp(untracked_files_arg, "all"))
diff --git a/t/t7502-status.sh b/t/t7502-status.sh
index 0d24e25..d84bda1 100755
--- a/t/t7502-status.sh
+++ b/t/t7502-status.sh
@@ -79,6 +79,28 @@ cat >expect <<EOF
#
# 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
+# 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:
# (use "git add <file>..." to include in what will be committed)
#
@@ -91,9 +113,6 @@ cat >expect <<EOF
# untracked
EOF
test_expect_success 'status -unormal' '
- mkdir dir3 &&
- : > dir3/untracked1 &&
- : > dir3/untracked2 &&
git status -unormal >output &&
test_cmp expect output
'
diff --git a/wt-status.c b/wt-status.c
index 25d9985..23017e4 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -348,7 +348,10 @@ void wt_status_print(struct wt_status *s)
wt_status_print_changed(s);
if (wt_status_submodule_summary)
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)
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");
else if (s->is_initial)
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
printf("nothing to commit (working directory clean)\n");
}
diff --git a/wt-status.h b/wt-status.h
index 54f756d..78add09 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -12,7 +12,8 @@ enum color_wt_status {
};
enum untracked_status_type {
- SHOW_NORMAL_UNTRACKED_FILES = 1,
+ SHOW_NO_UNTRACKED_FILES,
+ SHOW_NORMAL_UNTRACKED_FILES,
SHOW_ALL_UNTRACKED_FILES
};
extern enum untracked_status_type show_untracked_files;
--
1.5.6.rc0.160.gf7c043.dirty
next prev parent reply other threads:[~2008-06-09 7:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-27 9:29 [PATCH] Ensure that commit/status don't stat all files when core.ignoreStat = true Marius Storm-Olsen
2008-05-27 20:00 ` Junio C Hamano
2008-05-27 20:21 ` Marius Storm-Olsen
2008-05-30 11:14 ` [PATCH 1/3] Clearify the documentation for core.ignoreStat Marius Storm-Olsen
2008-05-30 8:54 ` [PATCH 2/3] Introduce core.showUntrackedFiles to make it possible to disable showing of untracked files Simon Hausmann
2008-05-30 12:38 ` [PATCH 3/3] Add shortcut in refresh_cache_ent() for marked entries Marius Storm-Olsen
2008-05-30 13:14 ` Marius Storm-Olsen
2008-05-30 13:10 ` [PATCH 2/3] Introduce core.showUntrackedFiles to make it possible to disable showing of untracked files Marius Storm-Olsen
2008-05-30 13:16 ` Marius Storm-Olsen
2008-05-30 20:27 ` Junio C Hamano
2008-05-31 6:41 ` Marius Storm-Olsen
2008-06-03 13:09 ` [PATCH] Add an optional <mode> argument to commit/status -u|--untracked-files option Marius Storm-Olsen
2008-06-03 13:12 ` [PATCH] Add configuration option for default untracked files mode Marius Storm-Olsen
2008-06-03 20:02 ` [PATCH] Add an optional <mode> argument to commit/status -u|--untracked-files option Junio C Hamano
2008-06-03 21:00 ` Marius Storm-Olsen
2008-06-05 8:31 ` [PATCH 1/3] " Marius Storm-Olsen
2008-06-05 12:22 ` [PATCH 2/3] Add argument 'no' commit/status option -u|--untracked-files Marius Storm-Olsen
2008-06-05 12:47 ` [PATCH 3/3] Add configuration option for default untracked files mode Marius Storm-Olsen
2008-06-07 1:55 ` [PATCH 1/3] Add an optional <mode> argument to commit/status -u|--untracked-files option Junio C Hamano
2008-06-09 6:54 ` Marius Storm-Olsen
2008-06-05 8:31 ` Marius Storm-Olsen
2008-06-05 12:22 ` Marius Storm-Olsen [this message]
2008-06-05 12:47 ` [PATCH 3/3] Add configuration option for default untracked files mode Marius Storm-Olsen
2008-06-10 6:23 ` [PATCH 1/3] Add an optional <mode> argument to commit/status -u|--untracked-files option Junio C Hamano
2008-06-03 20:14 ` [PATCH] " Jeff King
2008-06-03 21:17 ` Marius Storm-Olsen
2008-06-03 22:27 ` Jeff King
2008-06-03 22:26 ` しらいしななこ
[not found] ` <200806032227.m53MRLeD005668@mi0.bluebottle.com>
2008-06-03 22:53 ` Jeff King
2008-06-06 6:32 ` Alex Riesen
2008-06-06 6:56 ` Marius Storm-Olsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6ce4457c92b77210ceceeddb32cf30ca65103ed.1212995703.git.marius@trolltech.com \
--to=marius@trolltech.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).