Re: [PATCH/RFC] grep: Add --directories option.
From: Michał Kiedrowicz <hidden>
Date: 2016-06-15 22:47:02
Hi, René Scharfe [off-list ref] wrote:
I suspect the patch would shrink significantly if you moved "int recurse" into struct grep_opt, because then you wouln't need to add it as a parameter to the grep_* functions.
Yes. At the beginning, I placed 'int recurse' in that struct. However, I thought that this struct does not say anything about selecting files, but it says how to grep files (invert, count, fixed [string], binary etc.). Most of opts (if not all) are used in grep.c, not builtin-grep.c.
quoted
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index 7868af8..6d1faf4 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh@@ -22,7 +22,9 @@ test_expect_success setup ' echo zzz > z && mkdir t && echo test >t/t && - git add file w x y z t/t && + mkdir t/a && + echo aa aa aa aa >t/a/a && + git add file w x y z t/t t/a/a &&This conflicts with a recent change.
Yeah, I found out that...
It seems your patch still allows recursion, one level deep. In git's repo: $ grep -l --directories=skip GNU compat $ grep -l --directories=skip GNU compat/* compat/qsort.c compat/snprintf.c $ git grep -l --directories=skip GNU compat compat/qsort.c compat/snprintf.c $ git grep -l --directories=skip GNU compat/* compat/fnmatch/fnmatch.c compat/fnmatch/fnmatch.h compat/nedmalloc/malloc.c.h compat/nedmalloc/nedmalloc.c compat/nedmalloc/nedmalloc.h compat/qsort.c compat/regex/regex.c compat/regex/regex.h compat/snprintf.c René
Actually, this is what I wanted: Do not descend to subdirectories of selected directories. After a while, I think this action should be called "read [files in that directory]", not "skip".