grep: stop looking at random places for .gitattributes
commit55c61688ea1e41f4a8c26f957bf1bc43cd39ed97
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 12 Oct 2012 10:49:38 +0000 (12 17:49 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Oct 2012 15:24:44 +0000 (12 08:24 -0700)
tree42cb9a2a8aa7492518e7cc25546359e7615e82b1
parent40701adbcbbc1e3e4485562a36343f4781e62be5
grep: stop looking at random places for .gitattributes

grep searches for .gitattributes using "name" field in struct
grep_source but that field is not real on-disk path name. For example,
"grep pattern rev" fills the field with "rev:path", and Git looks for
.gitattributes in the (non-existent but exploitable) path "rev:path"
instead of "path".

This patch passes real paths down to grep_source_load_driver() when:

 - grep on work tree
 - grep on the index
 - grep a commit (or a tag if it points to a commit)

so that these cases look up .gitattributes at proper paths.
.gitattributes lookup is disabled in all other cases.

Initial-work-by: Jeff King <peff@peff.net>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c
grep.c
grep.h
t/t7008-grep-binary.sh