{"thread":{"id":"13870","subject":"[PATCH 3/3] Add configuration option for default untracked files mode","startedAt":"2008-06-05T12:22:56Z","lastAt":"2008-06-05T12:47:50Z","messageCount":2,"participants":["Marius Storm-Olsen"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"79209","messageId":"f6ce4457c92b77210ceceeddb32cf30ca65103ed.1212995703.git.marius@trolltech.com","threadId":"13870","inReplyTo":"c756e040b06883cc070bb24954111b4dcd457d2c.1212995703.git.marius@trolltech.com","subject":"[PATCH 2/3] Add argument 'no' commit/status option -u|--untracked-files","fromName":"Marius Storm-Olsen","fromEmail":"marius@trolltech.com","sentAt":"2008-06-05T12:22:56Z","receivedAt":"2008-06-05T12:22:56Z","isPatch":true,"sender":{"key":"marius@trolltech.com","avatar":"https://gravatar.com/avatar/a40071d8f651862c6ab10bd7996f0ad84d94f06c0399de9e3fa4f06beb390a71?d=mp&s=160"},"body":"This new argument teaches Git to not look for any untracked files,\nsaving cycles on slow file systems, or large repos.\n\nSigned-off-by: Marius Storm-Olsen <marius@trolltech.com>\n---\n Documentation/git-commit.txt |    1 +\n builtin-commit.c             |    4 +++-\n t/t7502-status.sh            |   25 ++++++++++++++++++++++---\n wt-status.c                  |    7 ++++++-\n wt-status.h                  |    3 ++-\n 5 files changed, 34 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex cc4374a..a6db831 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -157,6 +157,7 @@ The mode parameter is optional, and is used to specify\n the handling of untracked files. The possible options are:\n +\n --\n+\t\t- 'no'     - Show no untracked files\n \t\t- 'normal' - Shows untracked files and directories\n \t\t- 'all'    - Also shows individual files in untracked directories.\n --\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 95cdb82..f3e524a 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -103,7 +103,7 @@ static struct option builtin_commit_options[] = {\n \tOPT_BOOLEAN('o', \"only\", &only, \"commit only specified files\"),\n \tOPT_BOOLEAN('n', \"no-verify\", &no_verify, \"bypass pre-commit hook\"),\n \tOPT_BOOLEAN(0, \"amend\", &amend, \"amend previous commit\"),\n-\t{ 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\" },\n+\t{ 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\" },\n \tOPT_BOOLEAN(0, \"allow-empty\", &allow_empty, \"ok to record an empty change\"),\n \tOPT_STRING(0, \"cleanup\", &cleanup_arg, \"default\", \"how to strip spaces and #comments from message\"),\n \n@@ -798,6 +798,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \n \tif (!untracked_files_arg)\n \t\t; /* default already initialized */\n+\telse if (!strcmp(untracked_files_arg, \"no\"))\n+\t\tshow_untracked_files = SHOW_NO_UNTRACKED_FILES;\n \telse if (!strcmp(untracked_files_arg, \"normal\"))\n \t\tshow_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n \telse if (!strcmp(untracked_files_arg, \"all\"))\ndiff --git a/t/t7502-status.sh b/t/t7502-status.sh\nindex 0d24e25..d84bda1 100755\n--- a/t/t7502-status.sh\n+++ b/t/t7502-status.sh\n@@ -79,6 +79,28 @@ cat >expect <<EOF\n #\n #\tmodified:   dir1/modified\n #\n+# Untracked files not listed (use -u option to show untracked files)\n+EOF\n+test_expect_success 'status -uno' '\n+\tmkdir dir3 &&\n+\t: > dir3/untracked1 &&\n+\t: > dir3/untracked2 &&\n+\tgit status -uno >output &&\n+\ttest_cmp expect output\n+'\n+\n+cat >expect <<EOF\n+# On branch master\n+# Changes to be committed:\n+#   (use \"git reset HEAD <file>...\" to unstage)\n+#\n+#\tnew file:   dir2/added\n+#\n+# Changed but not updated:\n+#   (use \"git add <file>...\" to update what will be committed)\n+#\n+#\tmodified:   dir1/modified\n+#\n # Untracked files:\n #   (use \"git add <file>...\" to include in what will be committed)\n #\n@@ -91,9 +113,6 @@ cat >expect <<EOF\n #\tuntracked\n EOF\n test_expect_success 'status -unormal' '\n-\tmkdir dir3 &&\n-\t: > dir3/untracked1 &&\n-\t: > dir3/untracked2 &&\n \tgit status -unormal >output &&\n \ttest_cmp expect output\n '\ndiff --git a/wt-status.c b/wt-status.c\nindex 25d9985..23017e4 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -348,7 +348,10 @@ void wt_status_print(struct wt_status *s)\n \twt_status_print_changed(s);\n \tif (wt_status_submodule_summary)\n \t\twt_status_print_submodule_summary(s);\n-\twt_status_print_untracked(s);\n+\tif (show_untracked_files)\n+\t\twt_status_print_untracked(s);\n+\telse if (s->commitable)\n+\t\t fprintf(s->fp, \"# Untracked files not listed (use -u option to show untracked files)\\n\");\n \n \tif (s->verbose && !s->is_initial)\n \t\twt_status_print_verbose(s);\n@@ -363,6 +366,8 @@ void wt_status_print(struct wt_status *s)\n \t\t\tprintf(\"nothing added to commit but untracked files present (use \\\"git add\\\" to track)\\n\");\n \t\telse if (s->is_initial)\n \t\t\tprintf(\"nothing to commit (create/copy files and use \\\"git add\\\" to track)\\n\");\n+\t\telse if (!show_untracked_files)\n+\t\t\tprintf(\"nothing to commit (use -u to show untracked files)\\n\");\n \t\telse\n \t\t\tprintf(\"nothing to commit (working directory clean)\\n\");\n \t}\ndiff --git a/wt-status.h b/wt-status.h\nindex 54f756d..78add09 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -12,7 +12,8 @@ enum color_wt_status {\n };\n \n enum untracked_status_type {\n-\tSHOW_NORMAL_UNTRACKED_FILES = 1,\n+\tSHOW_NO_UNTRACKED_FILES,\n+\tSHOW_NORMAL_UNTRACKED_FILES,\n \tSHOW_ALL_UNTRACKED_FILES\n };\n extern enum untracked_status_type show_untracked_files;\n-- \n1.5.6.rc0.160.gf7c043.dirty\n"},{"id":"79207","messageId":"3a9bed01c38e8f10dbde8f422e9c039faef126b1.1212995703.git.marius@trolltech.com","threadId":"13870","inReplyTo":"f6ce4457c92b77210ceceeddb32cf30ca65103ed.1212995703.git.marius@trolltech.com","subject":"[PATCH 3/3] Add configuration option for default untracked files mode","fromName":"Marius Storm-Olsen","fromEmail":"marius@trolltech.com","sentAt":"2008-06-05T12:47:50Z","receivedAt":"2008-06-05T12:47:50Z","isPatch":true,"sender":{"key":"marius@trolltech.com","avatar":"https://gravatar.com/avatar/a40071d8f651862c6ab10bd7996f0ad84d94f06c0399de9e3fa4f06beb390a71?d=mp&s=160"},"body":"By default, the untracked files mode for commit/status is 'normal'\n\nSigned-off-by: Marius Storm-Olsen <marius@trolltech.com>\n---\n Documentation/config.txt     |   19 +++++++++++++++++++\n Documentation/git-commit.txt |    4 ++++\n t/t7502-status.sh            |   18 ++++++++++++++++++\n wt-status.c                  |   13 +++++++++++++\n 4 files changed, 54 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex c298dc2..7ce7816 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1010,6 +1010,25 @@ status.relativePaths::\n \trelative to the repository root (this was the default for git\n \tprior to v1.5.4).\n \n+status.showUntrackedFiles::\n+\tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n+\tfiles which are not currently tracked by Git. Directories which\n+\tcontain only untracked files, are shown with the directory name\n+\tonly. Showing untracked files means that Git needs to lstat() all\n+\tall the files in the whole repository, which might be slow on some\n+\tsystems. So, this variable controls how the commands displays\n+\tthe untracked files. Possible values are:\n++\n+--\n+\t\t- 'no'     - Show no untracked files\n+\t\t- 'normal' - Shows untracked files and directories\n+\t\t- 'all'    - Shows also individual files in untracked directories.\n+--\n++\n+If this variable is not specified, it defaults to 'normal'.\n+This variable can be overridden with the -u|--untracked-files option\n+of linkgit:git-status[1] and linkgit:git-commit[1].\n+\n tar.umask::\n \tThis variable can be used to restrict the permission bits of\n \ttar archive entries.  The default is 0002, which turns off the\ndiff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt\nindex a6db831..1235aae 100644\n--- a/Documentation/git-commit.txt\n+++ b/Documentation/git-commit.txt\n@@ -161,6 +161,10 @@ the handling of untracked files. The possible options are:\n \t\t- 'normal' - Shows untracked files and directories\n \t\t- 'all'    - Also shows individual files in untracked directories.\n --\n++\n+See linkgit:git-config[1] for configuration variable\n+used to change the default for when the option is not\n+specified.\n \n -v|--verbose::\n \tShow unified diff between the HEAD commit and what\ndiff --git a/t/t7502-status.sh b/t/t7502-status.sh\nindex d84bda1..38a48b5 100755\n--- a/t/t7502-status.sh\n+++ b/t/t7502-status.sh\n@@ -89,6 +89,12 @@ test_expect_success 'status -uno' '\n \ttest_cmp expect output\n '\n \n+test_expect_success 'status (status.showUntrackedFiles no)' '\n+\tgit config status.showuntrackedfiles no\n+\tgit status >output &&\n+\ttest_cmp expect output\n+'\n+\n cat >expect <<EOF\n # On branch master\n # Changes to be committed:\n@@ -117,6 +123,12 @@ test_expect_success 'status -unormal' '\n \ttest_cmp expect output\n '\n \n+test_expect_success 'status (status.showUntrackedFiles normal)' '\n+\tgit config status.showuntrackedfiles normal\n+\tgit status >output &&\n+\ttest_cmp expect output\n+'\n+\n cat >expect <<EOF\n # On branch master\n # Changes to be committed:\n@@ -143,7 +155,13 @@ cat >expect <<EOF\n EOF\n test_expect_success 'status -uall' '\n \tgit status -uall >output &&\n+\ttest_cmp expect output\n+'\n+test_expect_success 'status (status.showUntrackedFiles all)' '\n+\tgit config status.showuntrackedfiles all\n+\tgit status >output &&\n \trm -rf dir3 &&\n+\tgit config --unset status.showuntrackedfiles &&\n \ttest_cmp expect output\n '\n \ndiff --git a/wt-status.c b/wt-status.c\nindex 23017e4..28c9e63 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -397,5 +397,18 @@ int git_status_config(const char *k, const char *v, void *cb)\n \t\twt_status_relative_paths = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"status.showuntrackedfiles\")) {\n+\t\tif (!v)\n+\t\t\treturn config_error_nonbool(v);\n+\t\telse if (!strcmp(v, \"no\"))\n+\t\t\tshow_untracked_files = SHOW_NO_UNTRACKED_FILES;\n+\t\telse if (!strcmp(v, \"normal\"))\n+\t\t\tshow_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;\n+\t\telse if (!strcmp(v, \"all\"))\n+\t\t\tshow_untracked_files = SHOW_ALL_UNTRACKED_FILES;\n+\t\telse\n+\t\t\treturn error(\"Invalid untracked files mode '%s'\", v);\n+\t\treturn 0;\n+\t}\n \treturn git_color_default_config(k, v, cb);\n }\n-- \n1.5.6.rc0.160.gf7c043.dirty\n"}]}