From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Git Mailing List <git@vger.kernel.org>
Cc: Pierre Habouzit <madcoder@debian.org>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 4/5] grep: remove global variable builtin_grep
Date: Thu, 07 May 2009 21:46:17 +0200 [thread overview]
Message-ID: <1241725577.4772.10.camel@ubuntu.ubuntu-domain> (raw)
In-Reply-To: <1241725380.4772.6.camel@ubuntu.ubuntu-domain>
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>
---
builtin-grep.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index f88a912..620399f 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -20,8 +20,6 @@
#endif
#endif
-static int builtin_grep;
-
static int grep_config(const char *var, const char *value, void *cb)
{
struct grep_opt *opt = cb;
@@ -432,7 +430,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
}
#endif
-static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
+static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
+ int external_grep_allowed)
{
int hit = 0;
int nr;
@@ -444,7 +443,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
* we grep through the checked-out files. It tends to
* be a lot more optimized
*/
- if (!cached && !builtin_grep) {
+ if (!cached && external_grep_allowed) {
hit = external_grep(opt, paths, cached);
if (hit >= 0)
return hit;
@@ -574,6 +573,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
{
int hit = 0;
int cached = 0;
+ int external_grep_allowed = 1;
int seen_dashdash = 0;
struct grep_opt opt;
struct object_array list = { 0, 0, NULL };
@@ -612,7 +612,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp("--no-ext-grep", arg)) {
- builtin_grep = 1;
+ external_grep_allowed = 0;
continue;
}
if (!strcmp("-a", arg) ||
@@ -823,7 +823,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
}
if (opt.color && !opt.color_external)
- builtin_grep = 1;
+ external_grep_allowed = 0;
if (!opt.pattern_list)
die("no pattern given.");
if ((opt.regflags != REG_NEWLINE) && opt.fixed)
@@ -874,7 +874,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
if (!list.nr) {
if (!cached)
setup_work_tree();
- return !grep_cache(&opt, paths, cached);
+ return !grep_cache(&opt, paths, cached, external_grep_allowed);
}
if (cached)
--
1.6.3
next prev parent reply other threads:[~2009-05-07 19:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 19:43 [PATCH 0/5] grep parseopt conversion René Scharfe
2009-05-07 19:44 ` [PATCH 1/5] parseopt: add OPT_NEGBIT René Scharfe
2009-05-08 5:01 ` Jeff King
2009-05-07 19:45 ` [PATCH 2/5] parseopt: add OPT_NUMBER_CALLBACK René Scharfe
2009-05-07 19:45 ` [PATCH 3/5] parseopt: add PARSE_OPT_NODASH René Scharfe
2009-05-07 19:46 ` René Scharfe [this message]
2009-05-07 19:46 ` [PATCH 5/5] grep: use parseopt René Scharfe
2009-05-16 9:44 ` Stephen Boyd
2009-05-17 19:45 ` René Scharfe
2009-05-20 22:05 ` [PATCH] grep: make callback functions static René Scharfe
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=1241725577.4772.10.camel@ubuntu.ubuntu-domain \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@debian.org \
/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).