{"thread":{"id":"14620","subject":"[PATCH 02/12] git-grep: support --no-external-grep","startedAt":"2008-07-23T14:55:49Z","lastAt":"2008-07-24T23:16:59Z","messageCount":3,"participants":["Nguyễn Thái Ngọc Duy","Alex Riesen","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":12},"messages":[{"id":"84507","messageId":"20080723145549.GA29067@laptop","threadId":"14620","inReplyTo":null,"subject":"[PATCH 02/12] git-grep: support --no-external-grep","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-07-23T14:55:49Z","receivedAt":"2008-07-23T14:55:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"this one is mainly for testing builtin grep\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin-grep.c |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-grep.c b/builtin-grep.c\nindex cc9ba6b..ee96d01 100644\n--- a/builtin-grep.c\n+++ b/builtin-grep.c\n@@ -20,6 +20,8 @@\n #endif\n #endif\n \n+static int no_external_grep;\n+\n /*\n  * git grep pathspecs are somewhat different from diff-tree pathspecs;\n  * pathname wildcards are allowed.\n@@ -386,7 +388,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)\n \t * we grep through the checked-out files. It tends to\n \t * be a lot more optimized\n \t */\n-\tif (!cached) {\n+\tif (!cached && !no_external_grep) {\n \t\thit = external_grep(opt, paths, cached);\n \t\tif (hit >= 0)\n \t\t\treturn hit;\n@@ -544,6 +546,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\tcached = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(\"--no-external-grep\", arg)) {\n+\t\t\tno_external_grep = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(\"-a\", arg) ||\n \t\t    !strcmp(\"--text\", arg)) {\n \t\t\topt.binary = GREP_BINARY_TEXT;\n-- \n1.5.5.GIT\n"},{"id":"84791","messageId":"20080724202634.GB3760@blimp.local","threadId":"14620","inReplyTo":"20080723145549.GA29067@laptop","subject":"Re: [PATCH 02/12] git-grep: support --no-external-grep","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-07-24T20:26:34Z","receivedAt":"2008-07-24T20:26:34Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Nguyễn Thái Ngọc Duy, Wed, Jul 23, 2008 16:55:49 +0200:\n>  \n> +static int no_external_grep;\n> +\n\nIf you have used direct logic instead of negative, your patch would\nhave been simplier and the code would be easier to understand. I.e.:\n\n+static int external_grep = 1;\n\n> @@ -386,7 +388,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)\n>  \t * we grep through the checked-out files. It tends to\n>  \t * be a lot more optimized\n>  \t */\n> -\tif (!cached) {\n> +\tif (!cached && !no_external_grep) {\n\n+\tif (!cached && external_grep) {\n\n> @@ -544,6 +546,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n>  \t\t\tcached = 1;\n>  \t\t\tcontinue;\n>  \t\t}\n> +\t\tif (!strcmp(\"--no-external-grep\", arg)) {\n> +\t\t\tno_external_grep = 1;\n> +\t\t\tcontinue;\n> +\t\t}\n\n+\t\tif (!strcmp(\"--no-external-grep\", arg)) {\n+\t\t\texternal_grep = 0;\n+\t\t\tcontinue;\n+\t\t}\n\nBTW, how about a config option for this? And maybe --external-grep={yes|no}\n"},{"id":"84803","messageId":"fcaeb9bf0807241616k787ea8cco75d1a93a3eb516@mail.gmail.com","threadId":"14620","inReplyTo":"20080724202634.GB3760@blimp.local","subject":"Re: [PATCH 02/12] git-grep: support --no-external-grep","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-07-24T23:16:59Z","receivedAt":"2008-07-24T23:16:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 7/25/08, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Nguyen Thai Ngoc Duy, Wed, Jul 23, 2008 16:55:49 +0200:\n>\n> >\n>  > +static int no_external_grep;\n>  > +\n>\n>\n> If you have used direct logic instead of negative, your patch would\n>  have been simplier and the code would be easier to understand. I.e.:\n\nPoint taken.\n\n>  +               if (!strcmp(\"--no-external-grep\", arg)) {\n>  +                       external_grep = 0;\n>  +                       continue;\n>  +               }\n>\n>  BTW, how about a config option for this? And maybe --external-grep={yes|no}\n\nI don't need --external-grep=yes now, but that would be good for\ntesting external grep. About config option, is it really needed?\n-- \nDuy\n"}]}