• J
    grep: respect diff attributes for binary-ness · 41b59bfc
    Jeff King 提交于
    There is currently no way for users to tell git-grep that a
    particular path is or is not a binary file; instead, grep
    always relies on its auto-detection (or the user specifying
    "-a" to treat all binary-looking files like text).
    
    This patch teaches git-grep to use the same attribute lookup
    that is used by git-diff. We could add a new "grep" flag,
    but that is unnecessarily complex and unlikely to be useful.
    Despite the name, the "-diff" attribute (or "diff=foo" and
    the associated diff.foo.binary config option) are really
    about describing the contents of the path. It's simply
    historical that diff was the only thing that cared about
    these attributes in the past.
    
    And if this simple approach turns out to be insufficient, we
    still have a backwards-compatible path forward: we can add a
    separate "grep" attribute, and fall back to respecting
    "diff" if it is unset.
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    41b59bfc
grep.c 30.2 KB