summaryrefslogtreecommitdiff
path: root/usage.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-02-17 17:21:41 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-02-17 17:21:41 -0800
commitaa2d3dbdf56e835e34c8255815019bcfee5066d2 (patch)
tree4ad0db82f6f37dba7c7e22b57437dc510b70c328 /usage.c
parentMerge branch 'js/range-diff-one-side-only' (diff)
parentusage: trace2 BUG() invocations (diff)
downloadtgif-aa2d3dbdf56e835e34c8255815019bcfee5066d2.tar.xz
Merge branch 'jt/trace2-BUG'
Even though invocations of "die()" were logged to the trace2 system, "BUG()"s were not, which has been corrected. * jt/trace2-BUG: usage: trace2 BUG() invocations
Diffstat (limited to 'usage.c')
-rw-r--r--usage.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/usage.c b/usage.c
index 1868a24f7a..1b206de36d 100644
--- a/usage.c
+++ b/usage.c
@@ -266,6 +266,10 @@ int BUG_exit_code;
static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_list params)
{
char prefix[256];
+ va_list params_copy;
+ static int in_bug;
+
+ va_copy(params_copy, params);
/* truncation via snprintf is OK here */
if (file)
@@ -274,6 +278,13 @@ static NORETURN void BUG_vfl(const char *file, int line, const char *fmt, va_lis
snprintf(prefix, sizeof(prefix), "BUG: ");
vreportf(prefix, fmt, params);
+
+ if (in_bug)
+ abort();
+ in_bug = 1;
+
+ trace2_cmd_error_va(fmt, params_copy);
+
if (BUG_exit_code)
exit(BUG_exit_code);
abort();