git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] grep: Add --directories option.

From
Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Date
Jul 10, 2009, 16:41 UTC
Message-ID
<20090710184119.072e5a0f@gmail.com>
In-Reply-To
<4A56EED7.9040008@lsrfire.ath.cx>
Hi,
René Scharfe <rene.scharfe@lsrfire.ath.cx> 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.

Show 15 quoted lines
> 
> > 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...
Show 26 quoted lines
> 
> 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".

Previous: Michał KiedrowiczNext: Stephen Boyd
Message 5 of 6 in “grep: Add --directories option.”
  1. grep: Add --directories option.Michał Kiedrowicz, Jul 9, 2009
  2. René ScharfeJul 10, 2009
  3. Junio C HamanoJul 10, 2009
  4. Michał KiedrowiczJul 10, 2009
  5. Michał KiedrowiczJul 10, 2009
  6. Stephen BoydJul 10, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.