Re: 'git grep needle rev' attempts to access 'rev:.../.gitattributes' in the worktree
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Oct 9, 2012, 12:01 UTC
- Message-ID
- <20121009120144.GA8780@do>
- In-Reply-To
- <CACsJy8BFmUr5_E47900T6j9Lgdvj96_dNbo2LHP5hLYq3w7ZLA@mail.gmail.com>
On Tue, Oct 09, 2012 at 04:38:32PM +0700, Nguyen Thai Ngoc Duy wrote:
> #5 0x0815e736 in userdiff_find_by_path (path=0x820e7f0 > "HEAD:Documentation/.gitattributes") at userdiff.c:278 > #6 0x081058ca in grep_source_load_driver (gs=0xbfffd978) at grep.c:1504
A bandage patch may look like this. But it does not solve the real problem:
- we should be able to look up in-tree .gitattributes, not just ignore like this patch does
- gs->name seems to be prepared for human consumption, not for accessing files. grep_file() with opt->relative is true can put quotes in gs->name, for example.
I feel like we should make this function a callback and let git-grep deal with driver loading itself.
-- 8< --
diff --git a/grep.c b/grep.c index edc7776..c5ed067 100644 --- a/grep.c +++ b/grep.c @@ -1501,7 +1501,8 @@ void grep_source_load_driver(struct grep_source *gs) return; grep_attr_lock(); - gs->driver = userdiff_find_by_path(gs->name); + if (gs->type == GREP_SOURCE_FILE) + gs->driver = userdiff_find_by_path(gs->name); if (!gs->driver) gs->driver = userdiff_find_by_name("default"); grep_attr_unlock(); -- 8< --
-- Duy