From ac1d33dd0205c52fb168ddaa53b40aeb6f1ea7b5 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Thu, 15 Sep 2011 20:26:02 +0200 Subject: [PATCH 1/2] grep: do not use --index in the short usage output Utilize the PARSE_OPT_NEGHELP option to show --no-index in the usage generated by parse-options. Signed-off-by: Bert Wesarg Signed-off-by: Junio C Hamano --- builtin-grep.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin-grep.c b/builtin-grep.c index 0ef849cb84..e3eeb77cc7 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -762,8 +762,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_BOOLEAN(0, "cached", &cached, "search in index instead of in the work tree"), - OPT_BOOLEAN(0, "index", &use_index, - "--no-index finds in contents not managed by git"), + { OPTION_BOOLEAN, 0, "index", &use_index, NULL, + "finds in contents not managed by git", + PARSE_OPT_NOARG | PARSE_OPT_NEGHELP }, OPT_GROUP(""), OPT_BOOLEAN('v', "invert-match", &opt.invert, "show non-matching lines"), From a9e643668aa932d93528fffa573a13a28eb54556 Mon Sep 17 00:00:00 2001 From: Bert Wesarg Date: Thu, 15 Sep 2011 20:26:03 +0200 Subject: [PATCH 2/2] grep --no-index: don't use git standard exclusions The --no-index mode is intended to be used outside of a git repository, and it does not make sense to apply the git standard exclusions outside a git repositories. Signed-off-by: Bert Wesarg Signed-off-by: Junio C Hamano --- builtin-grep.c | 1 - t/t7002-grep.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin-grep.c b/builtin-grep.c index e3eeb77cc7..a10946db3c 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -652,7 +652,6 @@ static int grep_directory(struct grep_opt *opt, const char **paths) int i, hit = 0; memset(&dir, 0, sizeof(dir)); - setup_standard_excludes(&dir); fill_directory(&dir, paths); for (i = 0; i < dir.nr; i++) { diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index bf4d4dcb2b..918d33f7d1 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -439,7 +439,6 @@ test_expect_success 'outside of git repository' ' mkdir -p non/git/sub && echo hello >non/git/file1 && echo world >non/git/sub/file2 && - echo ".*o*" >non/git/.gitignore && { echo file1:hello && echo sub/file2:world @@ -466,6 +465,7 @@ test_expect_success 'inside git repository but with --no-index' ' echo world >is/git/sub/file2 && echo ".*o*" >is/git/.gitignore && { + echo ".gitignore:.*o*" && echo file1:hello && echo sub/file2:world } >is/expect.full &&