{"thread":{"id":"28401","subject":"[PATCH 1/2] grep: do not use --index in the short usage output","startedAt":"2011-09-15T18:26:02Z","lastAt":"2011-09-28T20:01:21Z","messageCount":8,"participants":["Bert Wesarg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"175596","messageId":"2f376e61802a1a38c67698d5ec263d1807b1fcee.1316110876.git.bert.wesarg@googlemail.com","threadId":"28401","inReplyTo":null,"subject":"[PATCH 1/2] grep: do not use --index in the short usage output","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-09-15T18:26:02Z","receivedAt":"2011-09-15T18:26:02Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Utilize the PARSE_OPT_NEGHELP option to show --no-index in the usage\ngenerated by parse-options.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n builtin/grep.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 1c359c2..e0562b0 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -774,8 +774,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN(0, \"cached\", &cached,\n \t\t\t\"search in index instead of in the work tree\"),\n-\t\tOPT_BOOLEAN(0, \"index\", &use_index,\n-\t\t\t\"--no-index finds in contents not managed by git\"),\n+\t\t{ OPTION_BOOLEAN, 0, \"index\", &use_index, NULL,\n+\t\t\t\"finds in contents not managed by git\",\n+\t\t\tPARSE_OPT_NOARG | PARSE_OPT_NEGHELP },\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOLEAN('v', \"invert-match\", &opt.invert,\n \t\t\t\"show non-matching lines\"),\n-- \n1.7.6.789.gb4599\n"},{"id":"175597","messageId":"7b3551dd84a2bfec78c8db1d14dd2d0e6dda35f6.1316110876.git.bert.wesarg@googlemail.com","threadId":"28401","inReplyTo":"2f376e61802a1a38c67698d5ec263d1807b1fcee.1316110876.git.bert.wesarg@googlemail.com","subject":"[PATCH 2/2] grep --no-index: don't use git standard exclusions","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-09-15T18:26:03Z","receivedAt":"2011-09-15T18:26:03Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"The --no-index mode is intended to be used outside of a git repository, but\nenabling the git standard exclusions outside a git repositories does not make\nany sense. Especially if it is not possible to disable them.\n\nThus do not use the standard exclusions in --no-index mode.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n\nOn Wed, Jul 20, 2011 at 22:57, Junio C Hamano <gitster@pobox.com> wrote:\n>  - Since 3081623 (grep --no-index: allow use of \"git grep\" outside a git\n>   repository, 2010-01-15) and 59332d1 (Resurrect \"git grep --no-index\",\n>   2010-02-06), \"grep --no-index\" incorrectly paid attention to the\n>   exclude patterns. We shouldn't have, and we'd fix that bug.\n\nFix this bug.\n\n builtin/grep.c  |    1 -\n t/t7810-grep.sh |    2 +-\n 2 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex e0562b0..127584e 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -643,7 +643,6 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec)\n \tint i, hit = 0;\n \n \tmemset(&dir, 0, sizeof(dir));\n-\tsetup_standard_excludes(&dir);\n \n \tfill_directory(&dir, pathspec->raw);\n \tfor (i = 0; i < dir.nr; i++) {\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex 0d60016..4a05e79 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -554,7 +554,6 @@ test_expect_success 'outside of git repository' '\n \tmkdir -p non/git/sub &&\n \techo hello >non/git/file1 &&\n \techo world >non/git/sub/file2 &&\n-\techo \".*o*\" >non/git/.gitignore &&\n \t{\n \t\techo file1:hello &&\n \t\techo sub/file2:world\n@@ -581,6 +580,7 @@ test_expect_success 'inside git repository but with --no-index' '\n \techo world >is/git/sub/file2 &&\n \techo \".*o*\" >is/git/.gitignore &&\n \t{\n+\t\techo \".gitignore:.*o*\" &&\n \t\techo file1:hello &&\n \t\techo sub/file2:world\n \t} >is/expect.full &&\n-- \n1.7.6.789.gb4599\n"},{"id":"175600","messageId":"7vmxe5pp4n.fsf@alter.siamese.dyndns.org","threadId":"28401","inReplyTo":"7b3551dd84a2bfec78c8db1d14dd2d0e6dda35f6.1316110876.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 2/2] grep --no-index: don't use git standard exclusions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-15T19:44:08Z","receivedAt":"2011-09-15T19:44:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> On Wed, Jul 20, 2011 at 22:57, Junio C Hamano <gitster@pobox.com> wrote:\n>>  - Since 3081623 (grep --no-index: allow use of \"git grep\" outside a git\n>>   repository, 2010-01-15) and 59332d1 (Resurrect \"git grep --no-index\",\n>>   2010-02-06), \"grep --no-index\" incorrectly paid attention to the\n>>   exclude patterns. We shouldn't have, and we'd fix that bug.\n>\n> Fix this bug.\n\nOn a busy list like this, it is brutal to withhold the better clues you\ncertainly had when you wrote this message that would help people to locate\nthe original message you are quoting, and instead forcing everybody to go\nback 5000 messages in the archive to find it. E.g.\n\n    http://article.gmane.org/gmane.comp.version-control.git/177548\n    http://mid.gmane.org/7vzkk86577.fsf@alter.siamese.dyndns.org\n\nOr perhaps have\n\n    References: <7vzkk86577.fsf@alter.siamese.dyndns.org>\n\nin the header.\n\nAs to the patch, I think this addresses only one fourth of the issue\nidentified in that discussion (it is a good starting point, though).\n\nWith this change, it would now make sense to teach --[no-]exclude-standard\nto \"git grep\", and \"--exclude-standard\" is immediately useful when used\nwith \"--no-index\". When we add \"git grep --untracked-too\" (which lets us\nsearch in the working tree), people can add \"--no-exclude-standard\" to the\ncommand line to say \"I want to find the needle even from an ignored file\".\n\nThanks.\n"},{"id":"175653","messageId":"CAKPyHN2ewwLf6am3VQr_z4c3_Q5=saeLcZtuY-fEtUGr-41rKQ@mail.gmail.com","threadId":"28401","inReplyTo":"7vmxe5pp4n.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] grep --no-index: don't use git standard exclusions","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-09-16T18:23:54Z","receivedAt":"2011-09-16T18:23:54Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Thu, Sep 15, 2011 at 21:44, Junio C Hamano <gitster@pobox.com> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>> On Wed, Jul 20, 2011 at 22:57, Junio C Hamano <gitster@pobox.com> wrote:\n>>>  - Since 3081623 (grep --no-index: allow use of \"git grep\" outside a git\n>>>   repository, 2010-01-15) and 59332d1 (Resurrect \"git grep --no-index\",\n>>>   2010-02-06), \"grep --no-index\" incorrectly paid attention to the\n>>>   exclude patterns. We shouldn't have, and we'd fix that bug.\n>>\n>> Fix this bug.\n>\n> On a busy list like this, it is brutal to withhold the better clues you\n> certainly had when you wrote this message that would help people to locate\n> the original message you are quoting, and instead forcing everybody to go\n> back 5000 messages in the archive to find it. E.g.\n>\n>    http://article.gmane.org/gmane.comp.version-control.git/177548\n>    http://mid.gmane.org/7vzkk86577.fsf@alter.siamese.dyndns.org\n>\n> Or perhaps have\n>\n>    References: <7vzkk86577.fsf@alter.siamese.dyndns.org>\n>\n> in the header.\n\nSorry for this patch with insufficient references and context. I\nrealized it too late, and the time was short.\n\n>\n> As to the patch, I think this addresses only one fourth of the issue\n> identified in that discussion (it is a good starting point, though).\n>\n\nI thought to split the bug fixing from the new features. I already\nimplemented --exclude-standard, including --exclude=<patter>,\n--exclude-from=<file> and --exclude-per-directory=<file>. But it's not\nready because of missing tests and documentation. So I just spilled\nthis bug fix patch out and will now work on the next part.\n\n> With this change, it would now make sense to teach --[no-]exclude-standard\n> to \"git grep\", and \"--exclude-standard\" is immediately useful when used\n> with \"--no-index\". When we add \"git grep --untracked-too\" (which lets us\n> search in the working tree), people can add \"--no-exclude-standard\" to the\n> command line to say \"I want to find the needle even from an ignored file\".\n\nWould '--untracked-too' only be a synonym for '--no-index\n--exclude-standard', i.e. the current behavior?\n\nBert\n\n>\n> Thanks.\n>\n"},{"id":"176363","messageId":"7vty7xwrsf.fsf_-_@alter.siamese.dyndns.org","threadId":"28401","inReplyTo":"CAKPyHN2ewwLf6am3VQr_z4c3_Q5=saeLcZtuY-fEtUGr-41rKQ@mail.gmail.com","subject":"Re* [PATCH 2/2] grep --no-index: don't use git standard exclusions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-27T22:21:04Z","receivedAt":"2011-09-27T22:21:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> Would '--untracked-too' only be a synonym for '--no-index\n> --exclude-standard', i.e. the current behavior?\n\nThat basically would be the idea. Perhaps something like this on top of\na9e6436 (grep --no-index: don't use git standard exclusions, 2011-09-15).\n\n-- >8 --\nSubject: [PATCH 1/2] grep: teach --untracked and --exclude options\n\nIn a working tree of a git managed repository, \"grep --untracked\" would\nfind the specified patterns from files in untracked files in addition to\nits usual behaviour of finding them in the tracked files.\n\nBy default, when working with \"--no-index\" option, \"grep\" does not pay\nattention to .gitignore mechanism. \"grep --no-index --exclude\" can be\nused to tell the command to use .gitignore and stop reporting hits from\nfiles that would be ignored. Also, when working without \"--no-index\",\n\"grep\" honors .gitignore mechanism, and \"grep --no-exclude\" can be used\nto tell the command to include hits from files that are ignored.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/git-grep.txt |   15 ++++++++++++++-\n builtin-grep.c             |   25 ++++++++++++++++++-------\n 2 files changed, 32 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt\nindex e019e76..2ccfb90 100644\n--- a/Documentation/git-grep.txt\n+++ b/Documentation/git-grep.txt\n@@ -9,7 +9,7 @@ git-grep - Print lines matching a pattern\n SYNOPSIS\n --------\n [verse]\n-'git grep' [--cached]\n+'git grep' [--cached] [--untracked] [--excludes]\n \t   [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]\n \t   [-v | --invert-match] [-h|-H] [--full-name]\n \t   [-E | --extended-regexp] [-G | --basic-regexp]\n@@ -36,6 +36,19 @@ OPTIONS\n \tInstead of searching in the working tree files, check\n \tthe blobs registered in the index file.\n \n+--untracked::\n+\tIn addition to searching in the tracked files in the working\n+\ttree, search also in untracked files.\n+\n+--no-excludes::\n+\tAlso search in ignored files by not honoring the `.gitignore`\n+\tmechanism. Only useful with `--untracked`.\n+\n+--excludes::\n+\tDo not pay attention to ignored files specified via the\t`.gitignore`\n+\tmechanism.  Only useful when searching files in the current directory\n+\twith `--no-index`.\n+\n -a::\n --text::\n \tProcess binary files as if they were text.\ndiff --git a/builtin-grep.c b/builtin-grep.c\nindex a10946d..c6cfdf8 100644\n--- a/builtin-grep.c\n+++ b/builtin-grep.c\n@@ -646,12 +646,14 @@ static int grep_object(struct grep_opt *opt, const char **paths,\n \tdie(\"unable to grep from object of type %s\", typename(obj->type));\n }\n \n-static int grep_directory(struct grep_opt *opt, const char **paths)\n+static int grep_directory(struct grep_opt *opt, const char **paths, int exc_std)\n {\n \tstruct dir_struct dir;\n \tint i, hit = 0;\n \n \tmemset(&dir, 0, sizeof(dir));\n+\tif (exc_std)\n+\t\tsetup_standard_excludes(&dir);\n \n \tfill_directory(&dir, paths);\n \tfor (i = 0; i < dir.nr; i++) {\n@@ -749,7 +751,7 @@ static int help_callback(const struct option *opt, const char *arg, int unset)\n int cmd_grep(int argc, const char **argv, const char *prefix)\n {\n \tint hit = 0;\n-\tint cached = 0;\n+\tint cached = 0, untracked = 0, opt_exclude = -1;\n \tint seen_dashdash = 0;\n \tint external_grep_allowed__ignored;\n \tstruct grep_opt opt;\n@@ -764,6 +766,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_BOOLEAN, 0, \"index\", &use_index, NULL,\n \t\t\t\"finds in contents not managed by git\",\n \t\t\tPARSE_OPT_NOARG | PARSE_OPT_NEGHELP },\n+\t\tOPT_BOOLEAN(0, \"untracked\", &untracked,\n+\t\t\t\"search in both tracked and untracked files\"),\n+\t\tOPT_SET_INT(0, \"exclude\", &opt_exclude,\n+\t\t\t    \"search also in ignored files\", 1),\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOLEAN('v', \"invert-match\", &opt.invert,\n \t\t\t\"show non-matching lines\"),\n@@ -950,18 +956,23 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tpaths[1] = NULL;\n \t}\n \n-\tif (!use_index) {\n+\tif (!use_index && (untracked || cached))\n+\t\tdie(\"--cached or --untracked cannot be used with --no-index.\");\n+\n+\tif (!use_index || untracked) {\n \t\tint hit;\n-\t\tif (cached)\n-\t\t\tdie(\"--cached cannot be used with --no-index.\");\n+\t\tint use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude;\n \t\tif (list.nr)\n-\t\t\tdie(\"--no-index cannot be used with revs.\");\n-\t\thit = grep_directory(&opt, paths);\n+\t\t\tdie(\"--no-index or --untracked cannot be used with revs.\");\n+\t\thit = grep_directory(&opt, paths, use_exclude);\n \t\tif (use_threads)\n \t\t\thit |= wait_all();\n \t\treturn !hit;\n \t}\n \n+\tif (0 <= opt_exclude)\n+\t\tdie(\"--exclude or --no-exclude cannot be used for tracked contents.\");\n+\n \tif (!list.nr) {\n \t\tint hit;\n \t\tif (!cached)\n-- \n1.7.7.rc3.4.g8d714\n"},{"id":"176364","messageId":"7voby5wrpy.fsf_-_@alter.siamese.dyndns.org","threadId":"28401","inReplyTo":"7vty7xwrsf.fsf_-_@alter.siamese.dyndns.org","subject":"[PATCH 2/2] grep: --untracked and --exclude tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-27T22:22:33Z","receivedAt":"2011-09-27T22:22:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Test various combinations of these options and --no-index.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t7002-grep.sh |   34 +++++++++++++++++++++++++++++++++-\n 1 files changed, 33 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t7002-grep.sh b/t/t7002-grep.sh\nindex 918d33f..2cbbdcc 100755\n--- a/t/t7002-grep.sh\n+++ b/t/t7002-grep.sh\n@@ -455,6 +455,23 @@ test_expect_success 'outside of git repository' '\n \t\ttest_must_fail git grep o &&\n \t\tgit grep --no-index o >../../actual.sub &&\n \t\ttest_cmp ../../expect.sub ../../actual.sub\n+\t) &&\n+\n+\techo \".*o*\" >non/git/.gitignore &&\n+\t(\n+\t\tGIT_CEILING_DIRECTORIES=\"$(pwd)/non/git\" &&\n+\t\texport GIT_CEILING_DIRECTORIES &&\n+\t\tcd non/git &&\n+\t\ttest_must_fail git grep o &&\n+\t\tgit grep --no-index --exclude o >../actual.full &&\n+\t\ttest_cmp ../expect.full ../actual.full &&\n+\n+\t\t{\n+\t\t\techo \".gitignore:.*o*\"\n+\t\t\tcat ../expect.full\n+\t\t} >../expect.with.ignored &&\n+\t\tgit grep --no-index --no-exclude o >../actual.full &&\n+\t\ttest_cmp ../expect.with.ignored ../actual.full\n \t)\n '\n \n@@ -465,9 +482,12 @@ test_expect_success 'inside git repository but with --no-index' '\n \techo world >is/git/sub/file2 &&\n \techo \".*o*\" >is/git/.gitignore &&\n \t{\n-\t\techo \".gitignore:.*o*\" &&\n \t\techo file1:hello &&\n \t\techo sub/file2:world\n+\t} >is/expect.unignored &&\n+\t{\n+\t\techo \".gitignore:.*o*\" &&\n+\t\tcat is/expect.unignored\n \t} >is/expect.full &&\n \t: >is/expect.empty &&\n \techo file2:world >is/expect.sub\n@@ -476,12 +496,24 @@ test_expect_success 'inside git repository but with --no-index' '\n \t\tgit init &&\n \t\ttest_must_fail git grep o >../actual.full &&\n \t\ttest_cmp ../expect.empty ../actual.full &&\n+\n+\t\tgit grep --untracked o >../actual.unignored &&\n+\t\ttest_cmp ../expect.unignored ../actual.unignored &&\n+\n \t\tgit grep --no-index o >../actual.full &&\n \t\ttest_cmp ../expect.full ../actual.full &&\n+\n+\t\tgit grep --no-index --exclude o >../actual.unignored &&\n+\t\ttest_cmp ../expect.unignored ../actual.unignored &&\n+\n \t\tcd sub &&\n \t\ttest_must_fail git grep o >../../actual.sub &&\n \t\ttest_cmp ../../expect.empty ../../actual.sub &&\n+\n \t\tgit grep --no-index o >../../actual.sub &&\n+\t\ttest_cmp ../../expect.sub ../../actual.sub &&\n+\n+\t\tgit grep --untracked o >../../actual.sub &&\n \t\ttest_cmp ../../expect.sub ../../actual.sub\n \t)\n '\n-- \n1.7.7.rc3.4.g8d714\n"},{"id":"176450","messageId":"CAKPyHN3=mbtEkyFUBdZAJCEVXfJhwPVhVFWkNNfX-yhtw9498w@mail.gmail.com","threadId":"28401","inReplyTo":"7vty7xwrsf.fsf_-_@alter.siamese.dyndns.org","subject":"Re: Re* [PATCH 2/2] grep --no-index: don't use git standard exclusions","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2011-09-28T19:19:08Z","receivedAt":"2011-09-28T19:19:08Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Wed, Sep 28, 2011 at 00:21, Junio C Hamano <gitster@pobox.com> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>> Would '--untracked-too' only be a synonym for '--no-index\n>> --exclude-standard', i.e. the current behavior?\n>\n> That basically would be the idea. Perhaps something like this on top of\n> a9e6436 (grep --no-index: don't use git standard exclusions, 2011-09-15).\n>\n> -- >8 --\n> Subject: [PATCH 1/2] grep: teach --untracked and --exclude options\n\nI would still vote to name the option --exclude-standard, like it is\ndone in 'git ls-files'. Which also has a --exclude=<pattern> option.\nAnd I think a --exclude=<pattern> option would be useful for 'git\ngrep', too.\n\nElse:\n\nAcked-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\nThanks.\n\nBert\n\n>\n> In a working tree of a git managed repository, \"grep --untracked\" would\n> find the specified patterns from files in untracked files in addition to\n> its usual behaviour of finding them in the tracked files.\n>\n> By default, when working with \"--no-index\" option, \"grep\" does not pay\n> attention to .gitignore mechanism. \"grep --no-index --exclude\" can be\n> used to tell the command to use .gitignore and stop reporting hits from\n> files that would be ignored. Also, when working without \"--no-index\",\n> \"grep\" honors .gitignore mechanism, and \"grep --no-exclude\" can be used\n> to tell the command to include hits from files that are ignored.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  Documentation/git-grep.txt |   15 ++++++++++++++-\n>  builtin-grep.c             |   25 ++++++++++++++++++-------\n>  2 files changed, 32 insertions(+), 8 deletions(-)\n>\n> diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt\n> index e019e76..2ccfb90 100644\n> --- a/Documentation/git-grep.txt\n> +++ b/Documentation/git-grep.txt\n> @@ -9,7 +9,7 @@ git-grep - Print lines matching a pattern\n>  SYNOPSIS\n>  --------\n>  [verse]\n> -'git grep' [--cached]\n> +'git grep' [--cached] [--untracked] [--excludes]\n>           [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]\n>           [-v | --invert-match] [-h|-H] [--full-name]\n>           [-E | --extended-regexp] [-G | --basic-regexp]\n> @@ -36,6 +36,19 @@ OPTIONS\n>        Instead of searching in the working tree files, check\n>        the blobs registered in the index file.\n>\n> +--untracked::\n> +       In addition to searching in the tracked files in the working\n> +       tree, search also in untracked files.\n> +\n> +--no-excludes::\n> +       Also search in ignored files by not honoring the `.gitignore`\n> +       mechanism. Only useful with `--untracked`.\n> +\n> +--excludes::\n> +       Do not pay attention to ignored files specified via the `.gitignore`\n> +       mechanism.  Only useful when searching files in the current directory\n> +       with `--no-index`.\n> +\n>  -a::\n>  --text::\n>        Process binary files as if they were text.\n> diff --git a/builtin-grep.c b/builtin-grep.c\n> index a10946d..c6cfdf8 100644\n> --- a/builtin-grep.c\n> +++ b/builtin-grep.c\n> @@ -646,12 +646,14 @@ static int grep_object(struct grep_opt *opt, const char **paths,\n>        die(\"unable to grep from object of type %s\", typename(obj->type));\n>  }\n>\n> -static int grep_directory(struct grep_opt *opt, const char **paths)\n> +static int grep_directory(struct grep_opt *opt, const char **paths, int exc_std)\n>  {\n>        struct dir_struct dir;\n>        int i, hit = 0;\n>\n>        memset(&dir, 0, sizeof(dir));\n> +       if (exc_std)\n> +               setup_standard_excludes(&dir);\n>\n>        fill_directory(&dir, paths);\n>        for (i = 0; i < dir.nr; i++) {\n> @@ -749,7 +751,7 @@ static int help_callback(const struct option *opt, const char *arg, int unset)\n>  int cmd_grep(int argc, const char **argv, const char *prefix)\n>  {\n>        int hit = 0;\n> -       int cached = 0;\n> +       int cached = 0, untracked = 0, opt_exclude = -1;\n>        int seen_dashdash = 0;\n>        int external_grep_allowed__ignored;\n>        struct grep_opt opt;\n> @@ -764,6 +766,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n>                { OPTION_BOOLEAN, 0, \"index\", &use_index, NULL,\n>                        \"finds in contents not managed by git\",\n>                        PARSE_OPT_NOARG | PARSE_OPT_NEGHELP },\n> +               OPT_BOOLEAN(0, \"untracked\", &untracked,\n> +                       \"search in both tracked and untracked files\"),\n> +               OPT_SET_INT(0, \"exclude\", &opt_exclude,\n> +                           \"search also in ignored files\", 1),\n>                OPT_GROUP(\"\"),\n>                OPT_BOOLEAN('v', \"invert-match\", &opt.invert,\n>                        \"show non-matching lines\"),\n> @@ -950,18 +956,23 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n>                paths[1] = NULL;\n>        }\n>\n> -       if (!use_index) {\n> +       if (!use_index && (untracked || cached))\n> +               die(\"--cached or --untracked cannot be used with --no-index.\");\n> +\n> +       if (!use_index || untracked) {\n>                int hit;\n> -               if (cached)\n> -                       die(\"--cached cannot be used with --no-index.\");\n> +               int use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude;\n>                if (list.nr)\n> -                       die(\"--no-index cannot be used with revs.\");\n> -               hit = grep_directory(&opt, paths);\n> +                       die(\"--no-index or --untracked cannot be used with revs.\");\n> +               hit = grep_directory(&opt, paths, use_exclude);\n>                if (use_threads)\n>                        hit |= wait_all();\n>                return !hit;\n>        }\n>\n> +       if (0 <= opt_exclude)\n> +               die(\"--exclude or --no-exclude cannot be used for tracked contents.\");\n> +\n>        if (!list.nr) {\n>                int hit;\n>                if (!cached)\n> --\n> 1.7.7.rc3.4.g8d714\n>\n>\n>\n"},{"id":"176453","messageId":"7vehz0zbam.fsf@alter.siamese.dyndns.org","threadId":"28401","inReplyTo":"CAKPyHN3=mbtEkyFUBdZAJCEVXfJhwPVhVFWkNNfX-yhtw9498w@mail.gmail.com","subject":"Re: Re* [PATCH 2/2] grep --no-index: don't use git standard exclusions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-28T20:01:21Z","receivedAt":"2011-09-28T20:01:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> I would still vote to name the option --exclude-standard, like it is\n> done in 'git ls-files'.\n\nThanks for catching.\n"}]}