From: Jeff King <peff@peff•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: El_Hoy <eloyesp@gmail•com>, git@vger•kernel.org
Subject: Re: Making git grep ignore binary the default
Date: Sat, 18 Oct 2025 06:22:09 -0400 [thread overview]
Message-ID: <20251018102209.GH1060824@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqsefhxlmd.fsf@gitster.g>
On Fri, Oct 17, 2025 at 02:29:46PM -0700, Junio C Hamano wrote:
> 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.
I do think there is one difference between git-grep and regular grep
here: the input file selection.
In "grep", the default set of files to search is nothing, and you have
to tell it which files to look at. So aside from overly broad globs, the
problem solves itself when you just don't pass in the binary paths.
But in git-grep, the default set of files to search is everything in the
repository! So it is very easy to noisy hits from uninteresting files.
I think binary-ness of the files is a red herring, though. There are
plenty of text files that are not interesting to grep either. I almost
never want to see hits from po/ in git.git, for example. I get by with
"^po/", or even "'*.c'" (extra single-quotes so that Git expands the
glob). But I'd be happy if I could set a configuration knob to say that
files with attribute X should be omitted from grep results (whether
binary, or some custom attribute that I assign in .git/info/attributes).
I think we've discussed this before, and digging in the archive found
this thread from 2012:
https://lore.kernel.org/git/4f1d2a8b.a2d8320a.50ec.576d@mx.google.com/
I think some of those ideas came to fruition. You can do:
git grep ':(attr:!binary)'
now (which obviously is harder than "-I", but the point is that it
extends to any attribute if you want). But I still think it would be
nice if there was a way to make it the default (without using an alias).
-Peff
next prev parent reply other threads:[~2025-10-18 10:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 15:00 Making git grep ignore binary the default El_Hoy
2025-10-17 21:29 ` Junio C Hamano
2025-10-17 23:29 ` Thomas Braun
2025-10-18 0:52 ` brian m. carlson
2025-10-18 14:16 ` rsbecker
2025-10-20 15:24 ` Thomas Braun
2025-10-20 17:20 ` El_Hoy
2025-10-21 7:27 ` Jeff King
2025-10-18 10:22 ` Jeff King [this message]
2025-10-18 16:01 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251018102209.GH1060824@coredump.intra.peff.net \
--to=peff@peff$(echo .)net \
--cc=eloyesp@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox