@matheusbsbs / matheus-bagliano / commits / 1b5fb44ad1
Fork 0

grep: remove global variable builtin_grep

Replace the only global variable in builtin-grep.c, builtin_grep, by a local one and a function parameter with reversed meaning. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed May 7, 2009 at 21:46 UTC 1b5fb44ad1131112fcc2b2b082fda61260e31570
1 file changed +7 -7
builtin-grep.c
+7 -7
@@ -20,8 +20,6 @@
20 #endif
21 #endif
22
23 -static int builtin_grep;
24 -
23 static int grep_config(const char *var, const char *value, void *cb)
24 {
25 struct grep_opt *opt = cb;
@@ -432,7 +430,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
430 }
431 #endif
432
435 -static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
433 +static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
434 + int external_grep_allowed)
435 {
436 int hit = 0;
437 int nr;
@@ -444,7 +443,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
443 * we grep through the checked-out files. It tends to
444 * be a lot more optimized
445 */
447 - if (!cached && !builtin_grep) {
446 + if (!cached && external_grep_allowed) {
447 hit = external_grep(opt, paths, cached);
448 if (hit >= 0)
449 return hit;
@@ -574,6 +573,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
573 {
574 int hit = 0;
575 int cached = 0;
576 + int external_grep_allowed = 1;
577 int seen_dashdash = 0;
578 struct grep_opt opt;
579 struct object_array list = { 0, 0, NULL };
@@ -612,7 +612,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
612 continue;
613 }
614 if (!strcmp("--no-ext-grep", arg)) {
615 - builtin_grep = 1;
615 + external_grep_allowed = 0;
616 continue;
617 }
618 if (!strcmp("-a", arg) ||
@@ -823,7 +823,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
823 }
824
825 if (opt.color && !opt.color_external)
826 - builtin_grep = 1;
826 + external_grep_allowed = 0;
827 if (!opt.pattern_list)
828 die("no pattern given.");
829 if ((opt.regflags != REG_NEWLINE) && opt.fixed)
@@ -874,7 +874,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
874 if (!list.nr) {
875 if (!cached)
876 setup_work_tree();
877 - return !grep_cache(&opt, paths, cached);
877 + return !grep_cache(&opt, paths, cached, external_grep_allowed);
878 }
879
880 if (cached)