Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
grep: do not do external grep on skip-worktree entries
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Wed, 30 Dec 2009 14:11:44 +0000
(21:11 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 31 Dec 2009 07:10:53 +0000
(23:10 -0800)
Skip-worktree entries are not on disk. We cannot use external grep in such
cases.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-grep.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
7fce6e3
)
diff --git
a/builtin-grep.c
b/builtin-grep.c
index 813fe9778ae443edafac338d67299368631e821d..25ee75d989d80382e370b5460f3d8f64ae086f6e 100644
(file)
--- a/
builtin-grep.c
+++ b/
builtin-grep.c
@@
-357,6
+357,21
@@
static void grep_add_color(struct strbuf *sb, const char *escape_seq)
strbuf_setlen(sb, sb->len - 1);
}
strbuf_setlen(sb, sb->len - 1);
}
+static int has_skip_worktree_entry(struct grep_opt *opt, const char **paths)
+{
+ int nr;
+ for (nr = 0; nr < active_nr; nr++) {
+ struct cache_entry *ce = active_cache[nr];
+ if (!S_ISREG(ce->ce_mode))
+ continue;
+ if (!pathspec_matches(paths, ce->name, opt->max_depth))
+ continue;
+ if (ce_skip_worktree(ce))
+ return 1;
+ }
+ return 0;
+}
+
static int external_grep(struct grep_opt *opt, const char **paths, int cached)
{
int i, nr, argc, hit, len, status;
static int external_grep(struct grep_opt *opt, const char **paths, int cached)
{
int i, nr, argc, hit, len, status;
@@
-365,7
+380,8
@@
static int external_grep(struct grep_opt *opt, const char **paths, int cached)
char *argptr = randarg;
struct grep_pat *p;
char *argptr = randarg;
struct grep_pat *p;
- if (opt->extended || (opt->relative && opt->prefix_length))
+ if (opt->extended || (opt->relative && opt->prefix_length)
+ || has_skip_worktree_entry(opt, paths))
return -1;
len = nr = 0;
push_arg("grep");
return -1;
len = nr = 0;
push_arg("grep");