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

Re: [PATCH] diff-lib: add idx/tree sanity check to oneway_diff

From
Jeff King <peff@peff.net>
Date
Jul 28, 2026, 17:12 UTC
Message-ID
<20260728171249.GA643101@coredump.intra.peff.net>
In-Reply-To
<xmqqo6frdqy5.fsf@gitster.g>
On Tue, Jul 28, 2026 at 09:22:42AM -0700, Junio C Hamano wrote:
Show 16 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> >> We could help humans that the BUG is not expected to fire and only
> >> to help static analysis by a crafted message, perhaps?
> >> 
> >>    if (!idx && !tree)
> >>  	BUG("Hey, Coverity, this does not happen");
> >
> > If we are helping humans we can probably afford to be a little more
> > eloquent. ;)
> 
> I do not mind eloquence but does the comment clearly say this is
> primarily for unconfusing static analyzers?  My first reaction to
> the message was "OK, you explained very well why this condition
> would never happen, but then why do you need to check and BUG() on
> it???"

I guess by the time I did all of the digging and thinking, my thought was that it _wasn't_ primarily for static analyzers, but to capture the output of that research. But then yeah, we don't really need the actual BUG(), but without it, it feels strange to even have the comment at all.

I think that's why I waffled on sending the patch at all.
Show 5 quoted lines
> But I guess the point is a future modification may invalidate this,
> in which case I agree with the comment.  If it is hard for static
> analysers to get it right, it probably is equally difficult to grok
> for AI agents many people seem to be using to draft their changes
> these days ;-).
Yeah, I guess it may help them, too. :)
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 12 in “diff: ignore unmerged paths outside prefix with --relative --cached”
  1. diff: ignore unmerged paths outside prefix with --relative --cachedJeff King, Jul 15, 2026
  2. Junio C HamanoJul 15, 2026
  3. 0/2 diff-lib relative-path cleanupsJeff King, Jul 26, 2026
  4. 1/2 diff-lib: drop stale comment about advancing o->posJeff King, Jul 26, 2026
  5. 2/2 diff-lib: skip paths outside prefix in oneway_diff()Jeff King, Jul 26, 2026
  6. Jeff KingJul 27, 2026
  7. Junio C HamanoJul 28, 2026
  8. diff-lib: add idx/tree sanity check to oneway_diffJeff King, Jul 28, 2026
  9. Junio C HamanoJul 28, 2026
  10. Jeff KingJul 28, 2026
  11. Junio C HamanoJul 26, 2026
  12. Junio C HamanoJul 24, 2026

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.