git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: Making git grep ignore binary the default

From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
Date
Oct 18, 2025, 14:16 UTC
Message-ID
<00af01dc4039$dd45e090$97d1a1b0$@nexbridge.com>
In-Reply-To
<aPLkuPgirAVHkERr@fruit.crustytoothpaste.net>
On October 17, 2025 8:52 PM, brian m. carlson wrote:
Show 41 quoted lines
>On 2025-10-17 at 23:29:22, Thomas Braun wrote:
>> Am 17.10.2025 um 23:29 schrieb Junio C Hamano:
>> > Simply because we have never needed to do something similar to "-a"
>> > and "-I" that we added in early 2006 for the past nearly 20 years.
>> > Also because GNU does not have any such thing to force "-a" or "-I"
>> > as default.  The biggest reason is that it would be surprising if
>> > such a change does not break existing scripts that have been written
>> > by people over the years.
>>
>> And if we only would have the config option "grep.ignoreBinary"
>> defaulting to false with no default change whatsoever? I always want
>> to ignore binaries when grepping and find it a bit tedious that I have
>> to spell it out all over again. And yes I do have an alias as well but
>> usually don't remember to use it.
>
>As Junio said, this could break existing scripts.  If I write a command which uses `git
>grep` and expects to find all matching files, it would not work on your system with
>`grep.ignoreBinary` set to true.
>
>For instance, if I am working on a project for a company and must exclude source
>code with a certain vendor's copyright (because we don't have permission to
>distribute their code), then it would be very bad if I accidentally distributed that
>company's binary files due to `git grep -l PATTERN | xargs rm -f` not matching them
>since it would violate the license.
>
>This is just an example, but there are lots of cases where people do really want to
>search every file.
>
>> I'm also curious what people are looking for in binary files with git grep.
>
>It's common to mark PDFs or PostScript files as binary because they often contain
>embedded binary fonts, but they are actually mostly text and can be usefully
>searched with grep.  For instance, I once created some awards for a non-profit
>based on combining standalone text-based PostScript code along with output from
>groff, so those independent pieces could end up being source that you might store
>in Git and search, even if many configurations would use `*.ps -text` in a system
>gitattributes file.
>
>Sometimes you also have images or such for a website, which contain XMP
>metadata (a form of XML-serialized RDF).  Finding those images which have certain
>author metadata or a certain license URL embedded in them could be valuable.

I agree that this will break scripts. There are quasi-binary files in some SQL spaces that really benefit from git grep working. Please do not make this the default.

Previous: brian m. carlsonNext: Thomas Braun
Message 5 of 10 in “Making git grep ignore binary the default”
  1. El_HoyOct 17, 2025
  2. Junio C HamanoOct 17, 2025
  3. Thomas BraunOct 17, 2025
  4. brian m. carlsonOct 18, 2025
  5. rsbecker@nexbridge.comOct 18, 2025
  6. Thomas BraunOct 20, 2025
  7. El_HoyOct 20, 2025
  8. Jeff KingOct 21, 2025
  9. Jeff KingOct 18, 2025
  10. Junio C HamanoOct 18, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.