summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e70b9a8)
raw | patch | inline | side by side (parent: e70b9a8)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Sat, 27 Dec 2008 08:21:03 +0000 (15:21 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 27 Dec 2008 22:30:46 +0000 (14:30 -0800) |
"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>
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>
builtin-grep.c | patch | blob | history | |
t/t7002-grep.sh | patch | blob | history |
diff --git a/builtin-grep.c b/builtin-grep.c
index 3c97c2c4d5e067706fb0987ac2390482107bc789..bebf15cd6f7d82b773f985ce238688b4759e3c37 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
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);
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 18fe6f2d576d35706b1a712292b58155680cc9dc..c4938544d4ca7c5e7e886a59144c9b10b7971748 100755 (executable)
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
git log --author=-0700 --pretty=tformat:%s >actual &&
>expect &&
test_cmp expect actual
+'
+test_expect_success 'grep with CE_VALID file' '
+ git update-index --assume-unchanged t/t &&
+ rm t/t &&
+ test "$(git grep --no-ext-grep t)" = "t/t:test" &&
+ git update-index --no-assume-unchanged t/t &&
+ git checkout t/t
'
test_done