Thread (2 messages) 2 messages, 2 authors, 2023-10-30

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

From: Taylor Blau <hidden>
Date: 2023-10-30 21:58:46

Possibly related (same subject, not in this thread)

On Thu, Oct 12, 2023 at 10:28:16AM -0700, Junio C Hamano wrote:
Erik Cervin Edin [off-list ref] writes:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help