diff options
author | Jeff King <peff@peff.net> | 2012-10-29 04:13:16 -0400 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2012-10-29 04:13:16 -0400 |
commit | e034d1bb927c17a3406a2bdbb8ccf710677a139d (patch) | |
tree | 58bc69a25324468d97a49aeb942c938211ccd442 /grep.c | |
parent | 58f3f9893dc287bd5b7ec4bbd3fc56b77e126e6c (diff) | |
parent | 55c61688ea1e41f4a8c26f957bf1bc43cd39ed97 (diff) | |
download | git-e034d1bb927c17a3406a2bdbb8ccf710677a139d.tar.gz |
Merge branch 'nd/grep-true-path'
"git grep -e pattern <tree>" asked the attribute system to read
"<tree>:.gitattributes" file in the working tree, which was
nonsense.
* nd/grep-true-path:
grep: stop looking at random places for .gitattributes
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1550,7 +1550,7 @@ int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size) struct grep_source gs; int r; - grep_source_init(&gs, GREP_SOURCE_BUF, NULL, NULL); + grep_source_init(&gs, GREP_SOURCE_BUF, NULL, NULL, NULL); gs.buf = buf; gs.size = size; @@ -1561,10 +1561,12 @@ int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size) } void grep_source_init(struct grep_source *gs, enum grep_source_type type, - const char *name, const void *identifier) + const char *name, const char *path, + const void *identifier) { gs->type = type; gs->name = name ? xstrdup(name) : NULL; + gs->path = path ? xstrdup(path) : NULL; gs->buf = NULL; gs->size = 0; gs->driver = NULL; @@ -1586,6 +1588,8 @@ void grep_source_clear(struct grep_source *gs) { free(gs->name); gs->name = NULL; + free(gs->path); + gs->path = NULL; free(gs->identifier); gs->identifier = NULL; grep_source_clear_data(gs); @@ -1678,7 +1682,8 @@ void grep_source_load_driver(struct grep_source *gs) return; grep_attr_lock(); - gs->driver = userdiff_find_by_path(gs->name); + if (gs->path) + gs->driver = userdiff_find_by_path(gs->path); if (!gs->driver) gs->driver = userdiff_find_by_name("default"); grep_attr_unlock(); |