summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f38f6b)
raw | patch | inline | side by side (parent: 4f38f6b)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Thu, 28 Aug 2008 13:04:30 +0000 (20:04 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 29 Aug 2008 05:46:16 +0000 (22:46 -0700) |
Unless used with --cached or grepping on a tree, "git grep" will
search on working directory, so set up worktree properly
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
search on working directory, so set up worktree properly
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/t1501-worktree.sh | patch | blob | history |
diff --git a/builtin-grep.c b/builtin-grep.c
index 631129ddfd0ffe06f919882d22cfc494d9553f50..3ded1ba9da9166c09fb1b65d315499e24036466d 100644 (file)
--- a/builtin-grep.c
+++ b/builtin-grep.c
paths[1] = NULL;
}
- if (!list.nr)
+ if (!list.nr) {
+ if (!cached)
+ setup_work_tree();
return !grep_cache(&opt, paths, cached);
+ }
if (cached)
die("both --cached and trees are given.");
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 8244b3a86f80110925613bac29e9f20ccc7303be..c039ee3fd86fc30a551a301066528a8574c34c1e 100755 (executable)
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
test_cmp diff-FILES.expected result
'
+test_expect_success 'git grep' '
+ (cd repo.git/work/sub &&
+ GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep -q dir/tracked)
+'
+
test_done