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

Re: [PATCH] diff: don't crash with empty argument to -G or -S

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 18, 2025, 19:29 UTC
Message-ID
<Z7TffynGALJM4KfH@tapette.crustytoothpaste.net>
In-Reply-To
<xmqqbjuzxgn3.fsf@gitster.g>
On 2025-02-18 at 18:16:32, Junio C Hamano wrote:
Show 11 quoted lines
> I agree BUG is unwelcome.  I am not sure about the value of
> forbidding an empty string (I am sure about forbidding NULL,
> though).  
> 
> If an empty matches everything, "git log -S" would skip changes that
> would keep the number of lines, right?  For the history of a project
> that keeps track of source code, such a "feature" would not be
> useful, but I can see a complaint by somebody who may want to keep
> track of a "list of things" one-item-per-line, if we had been
> allowing an empty string.  It would be a regression for such a niche
> user.

I actually just ran a `git grep -e ''` to see what it does, and it does indeed match every line, so presumably `git log -G` would do so as well.

I do see your argument that this could be useful for a limited number of use cases, but as someone who often keeps track of lists of things in text files and therefore could be a target for that feature, I still feel like this would be very much a corner case.

> Luckily, since we have stopped with a "BUG", we do not have to worry
> about backward compatibility in this case ;-)

I agree. The good news is that we haven't broken anyone's workflow, unless their workflow involves trying to trigger bugs.

Show 7 quoted lines
> So I'd say that it may be a bit premature for us to declare
> "anything useful", I am perfectly fine with the patch given here.
> If somebody who wants to maintain a text file, one-item-per-line
> that keeps track of a list of things to omit commits that do not
> change the number of items, they can drop "&& !*arg" part, tweak the
> message and add their own tests, once this fix lands and the dust
> settles.

Exactly. If there's one thing I've learned, it's that there are lots of users who will try new things, and I'm sure we'll get a report here or elsewhere that they'd like to add this feature if there's actually interest. Fortunately, I expect that it shouldn't be too hard to add such a feature.

-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
Previous: Junio C Hamano
Message 6 of 6 in “Crash on empty pickaxe argument”
  1. Jared Van BortelFeb 17, 2025
  2. brian m. carlsonFeb 17, 2025
  3. diff: don't crash with empty argument to -G or -Sbrian m. carlson, Feb 17, 2025
  4. Elijah NewrenFeb 17, 2025
  5. Junio C HamanoFeb 18, 2025
  6. brian m. carlsonFeb 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.