From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/5] grep: skip files outside sparse checkout area
Date: Wed, 29 Jul 2009 16:49:11 +1000 [thread overview]
Message-ID: <1248850154-5469-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1248850154-5469-2-git-send-email-pclouds@gmail.com>
---
Documentation/git-grep.txt | 4 +++-
builtin-grep.c | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 8c70020..8d9cba7 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -27,7 +27,9 @@ SYNOPSIS
DESCRIPTION
-----------
Look for specified patterns in the working tree files, blobs
-registered in the index file, or given tree objects.
+registered in the index file, or given tree objects. By default
+it will search in the working tree files. When in sparse checkout
+mode, it only searches checked-out files.
OPTIONS
diff --git a/builtin-grep.c b/builtin-grep.c
index ad0e0a5..55078cb 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -455,6 +455,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
continue;
if (!pathspec_matches(paths, ce->name, opt->max_depth))
continue;
+ if (ce->ce_flags & CE_VALID)
+ continue;
name = ce->name;
if (name[0] == '-') {
int len = ce_namelen(ce);
@@ -522,8 +524,11 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
continue;
hit |= grep_sha1(opt, ce->sha1, ce->name, 0);
}
- else
+ else {
+ if (ce->ce_flags & CE_VALID)
+ continue;
hit |= grep_file(opt, ce->name);
+ }
if (ce_stage(ce)) {
do {
nr++;
--
1.6.3.2.448.gdf8b6
next prev parent reply other threads:[~2009-07-29 6:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 6:49 [RFC PATCH 0/5] Sparse checkout resurrection Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` [PATCH 1/5] Prevent diff machinery from examining worktree outside sparse checkout Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` Nguyễn Thái Ngọc Duy [this message]
2009-07-29 6:49 ` [PATCH 3/5] gitignore: read from index if .gitignore is not in worktree Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` [PATCH 4/5] unpack_trees(): keep track of unmerged entries Nguyễn Thái Ngọc Duy
2009-07-29 6:49 ` [PATCH 5/5] unpack_trees(): add support for sparse checkout Nguyễn Thái Ngọc Duy
2009-07-29 11:48 ` Jakub Narebski
2009-07-29 23:32 ` Nguyen Thai Ngoc Duy
2009-07-30 0:42 ` Jakub Narebski
2009-07-31 16:55 ` [PATCH 3/5] gitignore: read from index if .gitignore is not in worktree Junio C Hamano
2009-07-31 16:42 ` [PATCH 2/5] grep: skip files outside sparse checkout area Junio C Hamano
2009-08-04 13:14 ` Nguyen Thai Ngoc Duy
2009-07-31 16:34 ` [PATCH 1/5] Prevent diff machinery from examining worktree outside sparse checkout Junio C Hamano
2009-07-31 21:18 ` [RFC PATCH 0/5] Sparse checkout resurrection skillzero
2009-08-04 13:20 ` Nguyen Thai Ngoc Duy
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=1248850154-5469-3-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.