On Mon, Jun 07, 2021 at 06:43:49PM +0200, Ævar Arnfjörð Bjarmason wrote: > 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