Skip to content

Commit fdef940

Browse files
committed
Merge branch 'ab/usage-error-docs'
Documentation updates, with unrelated comment updates, too. * ab/usage-error-docs: api docs: document that BUG() emits a trace2 error event api docs: document BUG() in api-error-handling.txt usage.c: don't copy/paste the same comment three times
2 parents 522010b + f6d25d7 commit fdef940

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

Documentation/technical/api-error-handling.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
Error reporting in git
22
======================
33

4-
`die`, `usage`, `error`, and `warning` report errors of various
5-
kinds.
4+
`BUG`, `die`, `usage`, `error`, and `warning` report errors of
5+
various kinds.
6+
7+
- `BUG` is for failed internal assertions that should never happen,
8+
i.e. a bug in git itself.
69

710
- `die` is for fatal application errors. It prints a message to
811
the user and exits with status 128.
@@ -20,6 +23,9 @@ kinds.
2023
without running into too many problems. Like `error`, it
2124
returns -1 after reporting the situation to the caller.
2225

26+
These reports will be logged via the trace2 facility. See the "error"
27+
event in link:api-trace2.txt[trace2 API].
28+
2329
Customizable error handlers
2430
---------------------------
2531

Documentation/technical/api-trace2.txt

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

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

usage.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ static NORETURN void usage_builtin(const char *err, va_list params)
5555
exit(129);
5656
}
5757

58+
/*
59+
* We call trace2_cmd_error_va() in the below functions first and
60+
* expect it to va_copy 'params' before using it (because an 'ap' can
61+
* only be walked once).
62+
*/
5863
static NORETURN void die_builtin(const char *err, va_list params)
5964
{
60-
/*
61-
* We call this trace2 function first and expect it to va_copy 'params'
62-
* before using it (because an 'ap' can only be walked once).
63-
*/
6465
trace2_cmd_error_va(err, params);
6566

6667
vreportf("fatal: ", err, params);
@@ -70,21 +71,13 @@ static NORETURN void die_builtin(const char *err, va_list params)
7071

7172
static void error_builtin(const char *err, va_list params)
7273
{
73-
/*
74-
* We call this trace2 function first and expect it to va_copy 'params'
75-
* before using it (because an 'ap' can only be walked once).
76-
*/
7774
trace2_cmd_error_va(err, params);
7875

7976
vreportf("error: ", err, params);
8077
}
8178

8279
static void warn_builtin(const char *warn, va_list params)
8380
{
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-
*/
8881
trace2_cmd_error_va(warn, params);
8982

9083
vreportf("warning: ", warn, params);

0 commit comments

Comments
 (0)