From 6577f542b3ab64594c7d7a7db752e96be7234fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 28 Aug 2008 20:04:30 +0700 Subject: grep: fix worktree setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- builtin-grep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'builtin-grep.c') diff --git a/builtin-grep.c b/builtin-grep.c index 631129ddf..3ded1ba9d 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -783,8 +783,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix) 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."); -- cgit v1.2.1