aboutsummaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2008-12-27 15:21:03 +0700
committerJunio C Hamano <gitster@pobox.com>2008-12-27 14:30:46 -0800
commit57d43466fbb4ffb4106b97593a96d714137dde2a (patch)
tree48db4a289f4c442803a5f7ea43f6e1fdc0398548 /builtin-grep.c
parente70b9a8bd2e25ced75cff2a2c26aed3f983425f8 (diff)
downloadgit-57d43466fbb4ffb4106b97593a96d714137dde2a.tar.gz
git-57d43466fbb4ffb4106b97593a96d714137dde2a.tar.xz
grep: grep cache entries if they are "assume unchanged"
"Assume unchanged" bit means "please pretend that I have never touched this file", so if user removes the file, we should not care. This patch teaches "git grep" to use cache version in such situations. External grep case has not been fixed yet. But given that on the platform that CE_VALID bit may be used like Windows, external grep is not available anyway, I would wait for people to raise their hands before touching it. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-grep.c')
-rw-r--r--builtin-grep.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index 3c97c2c4d..bebf15cd6 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -404,7 +404,12 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
continue;
if (!pathspec_matches(paths, ce->name))
continue;
- if (cached) {
+ /*
+ * If CE_VALID is on, we assume worktree file and its cache entry
+ * are identical, even if worktree file has been modified, so use
+ * cache version instead
+ */
+ if (cached || (ce->ce_flags & CE_VALID)) {
if (ce_stage(ce))
continue;
hit |= grep_sha1(opt, ce->sha1, ce->name, 0);