Skip to content

Commit 0ee10fd

Browse files
jonathantanmygitster
authored andcommitted
usage: add trace2 entry upon warning()
Emit a trace2 error event whenever warning() is called, just like when die(), error(), or usage() is called. This helps debugging issues that would trigger warnings but not errors. In particular, this might have helped debugging an issue I encountered with commit graphs at $DAYJOB [1]. There is a tradeoff between including potentially relevant messages and cluttering up the trace output produced. I think that warning() messages should be included in traces, because by its nature, Git is used over multiple invocations of the Git tool, and a failure (currently traced) in a Git invocation might be caused by an unexpected interaction in a previous Git invocation that only has a warning (currently untraced) as a symptom - as is the case in [1]. [1] https://lore.kernel.org/git/[email protected]/ Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 898f807 commit 0ee10fd

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Documentation/technical/api-trace2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ completed.)
466466

467467
`"error"`::
468468
This event is emitted when one of the `error()`, `die()`,
469-
or `usage()` functions are called.
469+
`warning()`, or `usage()` functions are called.
470470
+
471471
------------
472472
{

usage.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ static void error_builtin(const char *err, va_list params)
8181

8282
static void warn_builtin(const char *warn, va_list params)
8383
{
84+
/*
85+
* We call this trace2 function first and expect it to va_copy 'params'
86+
* before using it (because an 'ap' can only be walked once).
87+
*/
88+
trace2_cmd_error_va(warn, params);
89+
8490
vreportf("warning: ", warn, params);
8591
}
8692

0 commit comments

Comments
 (0)