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

Re: Bug: Git grep -f reads the filename relative to the repository root

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 30, 2023, 21:58 UTC
Message-ID
<ZUAnEVk65VQQE263@nand.local>
In-Reply-To
<xmqqedhzg37z.fsf@gitster.g>
On Thu, Oct 12, 2023 at 10:28:16AM -0700, Junio C Hamano wrote:
Show 20 quoted lines
> Erik Cervin Edin <erik@cervined.in> writes:
>
> > In the Git repository, I ran
> >
> >     echo tig > pattern-file &&
> >         echo git > xdiff/pattern-file &&
> >         cd xdfiff &&
> >         git grep -f pattern-file
> >
> > What did you expect to happen? (Expected behavior)
> >
> > Git grep -f to read the pattern-file, in the xdiff directory and
> > search for lines matching `git` in the xdiff directory.
>
> That does sound like a bug.  It should use the original directory as
> the base of the relative path computation, similar to the way how
> OPT_FILENAME() options are handled.
>
> Perhaps something along this line, but this is not even compile
> tested yet.

Just going through old mail that I didn't have a chance to respond to, the proposed patch that you included here does compile and pass t7810 for me, and the fix looks reasonable as-is. I don't think I see this patch on master, but would have no objections to you merging it down.

Thanks, Taylor

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “Bug: Git grep -f reads the filename relative to the repository root”
  1. Erik Cervin EdinOct 12, 2023
  2. Junio C HamanoOct 12, 2023
  3. Taylor BlauOct 30, 2023
  4. Junio C HamanoOct 31, 2023

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.