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

Re: [PATCH] xdiff: use BUG(...), not xdl_bug(...)

From
Jeff King <peff@peff.net>
Date
Jun 7, 2021, 19:44 UTC
Message-ID
<YL53AylIeN+YdOTA@coredump.intra.peff.net>
In-Reply-To
<patch-1.1-68bf1ba4d3-20210607T164305Z-avarab@gmail.com>
On Mon, Jun 07, 2021 at 06:43:49PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> The xdl_bug() function was introduced in
> e8adf23d1e (xdl_change_compact(): introduce the concept of a change
> group, 2016-08-22), let's use our usual BUG() function instead.
> 
> We'll now have meaningful line numbers if we encounter bugs in xdiff,
> and less code duplication.
Thanks, I think this is a good direction.

Back when that commit was originally done, we didn't include git-compat-util.h in xdiff at all, so we couldn't rely on Git-specific code (though I think BUG() did not even exist back then anyway!).

These days I think we're comfortable with the notion that there is no active upstream for xdiff, so we'd not be likely to send our changes anywhere (and thus dependencies on our helpers are not a problem). But there is one complication: libgit2 uses xdiff, too, and has pulled in our changes including xdl_bug().

I wondered if we could make it easier on them by keeping the change in one spot. But doing:

  static void xdl_bug(const char *msg)
  {
	BUG("%s", msg);
  }

is not really helpful, as it loses the line numbers. I guess we could do:

  #ifdef BUG
  #define xdl_bug(msg) BUG(msg)
  #else
  ...the current implementation
  #endif

But really, libgit2 could just as easily define their own BUG() as they see fit. Whether it is called xdl_bug() or BUG() in the call-sites is not really that important.

So I think this patch is fine in its current form.
-Peff
Previous: Ævar Arnfjörð Bjarmason
Message 2 of 2 in “xdiff: use BUG(...), not xdl_bug(...)”
  1. xdiff: use BUG(...), not xdl_bug(...)Ævar Arnfjörð Bjarmason, Jun 7, 2021
  2. Jeff KingJun 7, 2021

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.