Skip to content

Commit 463dca6

Browse files
committed
Merge branch 'sg/trace2-rename'
Rename environment variables that are used to control the "trace2" mechanism to a more readable name. * sg/trace2-rename: trace2: document the supported values of GIT_TRACE2* env variables trace2: rename environment variables to GIT_TRACE2*
2 parents 90f2d88 + 4e0d3aa commit 463dca6

File tree

13 files changed

+118
-91
lines changed

13 files changed

+118
-91
lines changed

Documentation/config/trace2.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,53 @@ command line arguments are not respected.
44

55
trace2.normalTarget::
66
This variable controls the normal target destination.
7-
It may be overridden by the `GIT_TR2` environment variable.
7+
It may be overridden by the `GIT_TRACE2` environment variable.
88
The following table shows possible values.
99

1010
trace2.perfTarget::
1111
This variable controls the performance target destination.
12-
It may be overridden by the `GIT_TR2_PERF` environment variable.
12+
It may be overridden by the `GIT_TRACE2_PERF` environment variable.
1313
The following table shows possible values.
1414

1515
trace2.eventTarget::
1616
This variable controls the event target destination.
17-
It may be overridden by the `GIT_TR2_EVENT` environment variable.
17+
It may be overridden by the `GIT_TRACE2_EVENT` environment variable.
1818
The following table shows possible values.
1919
+
2020
include::../trace2-target-values.txt[]
2121

2222
trace2.normalBrief::
2323
Boolean. When true `time`, `filename`, and `line` fields are
2424
omitted from normal output. May be overridden by the
25-
`GIT_TR2_BRIEF` environment variable. Defaults to false.
25+
`GIT_TRACE2_BRIEF` environment variable. Defaults to false.
2626

2727
trace2.perfBrief::
2828
Boolean. When true `time`, `filename`, and `line` fields are
2929
omitted from PERF output. May be overridden by the
30-
`GIT_TR2_PERF_BRIEF` environment variable. Defaults to false.
30+
`GIT_TRACE2_PERF_BRIEF` environment variable. Defaults to false.
3131

3232
trace2.eventBrief::
3333
Boolean. When true `time`, `filename`, and `line` fields are
3434
omitted from event output. May be overridden by the
35-
`GIT_TR2_EVENT_BRIEF` environment variable. Defaults to false.
35+
`GIT_TRACE2_EVENT_BRIEF` environment variable. Defaults to false.
3636

3737
trace2.eventNesting::
3838
Integer. Specifies desired depth of nested regions in the
3939
event output. Regions deeper than this value will be
40-
omitted. May be overridden by the `GIT_TR2_EVENT_NESTING`
40+
omitted. May be overridden by the `GIT_TRACE2_EVENT_NESTING`
4141
environment variable. Defaults to 2.
4242

4343
trace2.configParams::
4444
A comma-separated list of patterns of "important" config
4545
settings that should be recorded in the trace2 output.
4646
For example, `core.*,remote.*.url` would cause the trace2
4747
output to contain events listing each configured remote.
48-
May be overridden by the `GIT_TR2_CONFIG_PARAMS` environment
48+
May be overridden by the `GIT_TRACE2_CONFIG_PARAMS` environment
4949
variable. Unset by default.
5050

5151
trace2.destinationDebug::
5252
Boolean. When true Git will print error messages when a
5353
trace target destination cannot be opened for writing.
5454
By default, these errors are suppressed and tracing is
5555
silently disabled. May be overridden by the
56-
`GIT_TR2_DST_DEBUG` environment variable.
56+
`GIT_TRACE2_DST_DEBUG` environment variable.

Documentation/git.txt

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -660,26 +660,53 @@ of clones and fetches.
660660
When a curl trace is enabled (see `GIT_TRACE_CURL` above), do not dump
661661
data (that is, only dump info lines and headers).
662662

663-
`GIT_TR2`::
663+
`GIT_TRACE2`::
664664
Enables more detailed trace messages from the "trace2" library.
665-
Output from `GIT_TR2` is a simple text-based format for human
665+
Output from `GIT_TRACE2` is a simple text-based format for human
666666
readability.
667667
+
668-
The `GIT_TR2` variables can take many values. Any value available to
669-
the `GIT_TRACE` variables is also available to `GIT_TR2`. The `GIT_TR2`
670-
variables can also specify a Unix Domain Socket. See
671-
link:technical/api-trace2.html[Trace2 documentation] for full details.
668+
If this variable is set to "1", "2" or "true" (comparison
669+
is case insensitive), trace messages will be printed to
670+
stderr.
671+
+
672+
If the variable is set to an integer value greater than 2
673+
and lower than 10 (strictly) then Git will interpret this
674+
value as an open file descriptor and will try to write the
675+
trace messages into this file descriptor.
676+
+
677+
Alternatively, if the variable is set to an absolute path
678+
(starting with a '/' character), Git will interpret this
679+
as a file path and will try to append the trace messages
680+
to it. If the path already exists and is a directory, the
681+
trace messages will be written to files (one per process)
682+
in that directory, named according to the last component
683+
of the SID and an optional counter (to avoid filename
684+
collisions).
685+
+
686+
In addition, if the variable is set to
687+
`af_unix:[<socket_type>:]<absolute-pathname>`, Git will try
688+
to open the path as a Unix Domain Socket. The socket type
689+
can be either `stream` or `dgram`.
690+
+
691+
Unsetting the variable, or setting it to empty, "0" or
692+
"false" (case insensitive) disables trace messages.
693+
+
694+
See link:technical/api-trace2.html[Trace2 documentation]
695+
for full details.
696+
672697

673-
`GIT_TR2_EVENT`::
698+
`GIT_TRACE2_EVENT`::
674699
This setting writes a JSON-based format that is suited for machine
675-
interpretation. See link:technical/api-trace2.html[Trace2 documentation]
676-
for full details.
700+
interpretation.
701+
See `GIT_TRACE2` for available trace output options and
702+
link:technical/api-trace2.html[Trace2 documentation] for full details.
677703

678-
`GIT_TR2_PERF`::
679-
In addition to the text-based messages available in `GIT_TR2`, this
704+
`GIT_TRACE2_PERF`::
705+
In addition to the text-based messages available in `GIT_TRACE2`, this
680706
setting writes a column-based format for understanding nesting
681-
regions. See link:technical/api-trace2.html[Trace2 documentation]
682-
for full details.
707+
regions.
708+
See `GIT_TRACE2` for available trace output options and
709+
link:technical/api-trace2.html[Trace2 documentation] for full details.
683710

684711
`GIT_REDACT_COOKIES`::
685712
This can be set to a comma-separated list of strings. When a curl trace

Documentation/technical/api-trace2.txt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ formats in the future. This might be used to define a binary format,
2323
for example.
2424

2525
Trace2 is controlled using `trace2.*` config values in the system and
26-
global config files and `GIT_TR2*` environment variables. Trace2 does
26+
global config files and `GIT_TRACE2*` environment variables. Trace2 does
2727
not read from repo local or worktree config files or respect `-c`
2828
command line config settings.
2929

@@ -42,7 +42,7 @@ config setting.
4242
For example
4343

4444
------------
45-
$ export GIT_TR2=~/log.normal
45+
$ export GIT_TRACE2=~/log.normal
4646
$ git version
4747
git version 2.20.1.155.g426c96fcdb
4848
------------
@@ -71,13 +71,13 @@ $ cat ~/log.normal
7171
The performance format target (PERF) is a column-based format to
7272
replace GIT_TRACE_PERFORMANCE and is suitable for development and
7373
testing, possibly to complement tools like gprof. This format is
74-
enabled with the `GIT_TR2_PERF` environment variable or the
74+
enabled with the `GIT_TRACE2_PERF` environment variable or the
7575
`trace2.perfTarget` system or global config setting.
7676

7777
For example
7878

7979
------------
80-
$ export GIT_TR2_PERF=~/log.perf
80+
$ export GIT_TRACE2_PERF=~/log.perf
8181
$ git version
8282
git version 2.20.1.155.g426c96fcdb
8383
------------
@@ -104,14 +104,14 @@ $ cat ~/log.perf
104104
=== The Event Format Target
105105

106106
The event format target is a JSON-based format of event data suitable
107-
for telemetry analysis. This format is enabled with the `GIT_TR2_EVENT`
107+
for telemetry analysis. This format is enabled with the `GIT_TRACE2_EVENT`
108108
environment variable or the `trace2.eventTarget` system or global config
109109
setting.
110110

111111
For example
112112

113113
------------
114-
$ export GIT_TR2_EVENT=~/log.event
114+
$ export GIT_TRACE2_EVENT=~/log.event
115115
$ git version
116116
git version 2.20.1.155.g426c96fcdb
117117
------------
@@ -273,7 +273,7 @@ significantly affects program performance or behavior, such as
273273
Emits a "def_param" messages for "important" configuration
274274
settings.
275275
+
276-
The environment variable `GIT_TR2_CONFIG_PARAMS` or the `trace2.configParams`
276+
The environment variable `GIT_TRACE2_CONFIG_PARAMS` or the `trace2.configParams`
277277
config value can be set to a
278278
list of patterns of important configuration settings, for example:
279279
`core.*,remote.*.url`. This function will iterate over all config
@@ -465,7 +465,7 @@ Events are written as lines of the form:
465465
Note that this may contain embedded LF or CRLF characters that are
466466
not escaped, so the event may spill across multiple lines.
467467

468-
If `GIT_TR2_BRIEF` or `trace2.normalBrief` is true, the `time`, `filename`,
468+
If `GIT_TRACE2_BRIEF` or `trace2.normalBrief` is true, the `time`, `filename`,
469469
and `line` fields are omitted.
470470

471471
This target is intended to be more of a summary (like GIT_TRACE) and
@@ -533,7 +533,7 @@ This field is in anticipation of in-proc submodules in the future.
533533
15:33:33.532712 wt-status.c:2331 | d0 | main | region_leave | r1 | 0.127568 | 0.001504 | status | label:print
534534
------------
535535

536-
If `GIT_TR2_PERF_BRIEF` or `trace2.perfBrief` is true, the `time`, `file`,
536+
If `GIT_TRACE2_PERF_BRIEF` or `trace2.perfBrief` is true, the `time`, `file`,
537537
and `line` fields are omitted.
538538

539539
------------
@@ -598,7 +598,7 @@ The following key/value pairs are common to all events:
598598
`"repo":<repo-id>`::
599599
when present, is the integer repo-id as described previously.
600600

601-
If `GIT_TR2_EVENT_BRIEF` or `trace2.eventBrief` is true, the `file`
601+
If `GIT_TRACE2_EVENT_BRIEF` or `trace2.eventBrief` is true, the `file`
602602
and `line` fields are omitted from all events and the `time` field is
603603
only present on the "start" and "atexit" events.
604604

@@ -911,7 +911,7 @@ visited.
911911
The `category` field may be used in a future enhancement to
912912
do category-based filtering.
913913
+
914-
`GIT_TR2_EVENT_NESTING` or `trace2.eventNesting` can be used to
914+
`GIT_TRACE2_EVENT_NESTING` or `trace2.eventNesting` can be used to
915915
filter deeply nested regions and data events. It defaults to "2".
916916

917917
`"region_leave"`::
@@ -1039,8 +1039,8 @@ rev-list, and gc. This example also shows that fetch took
10391039
5.199 seconds and of that 4.932 was in ssh.
10401040
+
10411041
----------------
1042-
$ export GIT_TR2_BRIEF=1
1043-
$ export GIT_TR2=~/log.normal
1042+
$ export GIT_TRACE2_BRIEF=1
1043+
$ export GIT_TRACE2=~/log.normal
10441044
$ git fetch origin
10451045
...
10461046
----------------
@@ -1075,8 +1075,8 @@ its name as "gc", it also reports the hierarchy as "fetch/gc".
10751075
indented for clarity.)
10761076
+
10771077
----------------
1078-
$ export GIT_TR2_BRIEF=1
1079-
$ export GIT_TR2=~/log.normal
1078+
$ export GIT_TRACE2_BRIEF=1
1079+
$ export GIT_TRACE2=~/log.normal
10801080
$ git fetch origin
10811081
...
10821082
----------------
@@ -1134,8 +1134,8 @@ In this example, scanning for untracked files ran from +0.012568 to
11341134
+0.027149 (since the process started) and took 0.014581 seconds.
11351135
+
11361136
----------------
1137-
$ export GIT_TR2_PERF_BRIEF=1
1138-
$ export GIT_TR2_PERF=~/log.perf
1137+
$ export GIT_TRACE2_PERF_BRIEF=1
1138+
$ export GIT_TRACE2_PERF=~/log.perf
11391139
$ git status
11401140
...
11411141

@@ -1180,8 +1180,8 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
11801180
We can further investigate the time spent scanning for untracked files.
11811181
+
11821182
----------------
1183-
$ export GIT_TR2_PERF_BRIEF=1
1184-
$ export GIT_TR2_PERF=~/log.perf
1183+
$ export GIT_TRACE2_PERF_BRIEF=1
1184+
$ export GIT_TRACE2_PERF=~/log.perf
11851185
$ git status
11861186
...
11871187
$ cat ~/log.perf
@@ -1236,8 +1236,8 @@ int read_index_from(struct index_state *istate, const char *path,
12361236
This example shows that the index contained 3552 entries.
12371237
+
12381238
----------------
1239-
$ export GIT_TR2_PERF_BRIEF=1
1240-
$ export GIT_TR2_PERF=~/log.perf
1239+
$ export GIT_TRACE2_PERF_BRIEF=1
1240+
$ export GIT_TRACE2_PERF=~/log.perf
12411241
$ git status
12421242
...
12431243
$ cat ~/log.perf
@@ -1310,8 +1310,8 @@ Data events are tagged with the active thread name. They are used
13101310
to report the per-thread parameters.
13111311
+
13121312
----------------
1313-
$ export GIT_TR2_PERF_BRIEF=1
1314-
$ export GIT_TR2_PERF=~/log.perf
1313+
$ export GIT_TRACE2_PERF_BRIEF=1
1314+
$ export GIT_TRACE2_PERF=~/log.perf
13151315
$ git status
13161316
...
13171317
$ cat ~/log.perf

t/t0001-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ test_expect_success 'No extra GIT_* on alias scripts' '
9393
sed -n \
9494
-e "/^GIT_PREFIX=/d" \
9595
-e "/^GIT_TEXTDOMAINDIR=/d" \
96-
-e "/^GIT_TR2_PARENT/d" \
96+
-e "/^GIT_TRACE2_PARENT/d" \
9797
-e "/^GIT_/s/=.*//p" |
9898
sort
9999
EOF

t/t0210-trace2-normal.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ test_description='test trace2 facility (normal target)'
44
. ./test-lib.sh
55

66
# Turn off any inherited trace2 settings for this test.
7-
sane_unset GIT_TR2 GIT_TR2_PERF GIT_TR2_EVENT
8-
sane_unset GIT_TR2_BRIEF
9-
sane_unset GIT_TR2_CONFIG_PARAMS
7+
sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT
8+
sane_unset GIT_TRACE2_BRIEF
9+
sane_unset GIT_TRACE2_CONFIG_PARAMS
1010

1111
# Add t/helper directory to PATH so that we can use a relative
1212
# path to run nested instances of test-tool.exe (see 004child).
@@ -27,12 +27,12 @@ V=$(git version | sed -e 's/^git version //') && export V
2727
# to whatever filtering that target decides to do).
2828
# This script tests the normal target in isolation.
2929
#
30-
# Defer setting GIT_TR2 until the actual command line we want to test
30+
# Defer setting GIT_TRACE2 until the actual command line we want to test
3131
# because hidden git and test-tool commands run by the test harness
3232
# can contaminate our output.
3333

3434
# Enable "brief" feature which turns off "<clock> <file>:<line> " prefix.
35-
GIT_TR2_BRIEF=1 && export GIT_TR2_BRIEF
35+
GIT_TRACE2_BRIEF=1 && export GIT_TRACE2_BRIEF
3636

3737
# Basic tests of the trace2 normal stream. Since this stream is used
3838
# primarily with printf-style debugging/tracing, we do limited testing
@@ -54,7 +54,7 @@ GIT_TR2_BRIEF=1 && export GIT_TR2_BRIEF
5454

5555
test_expect_success 'normal stream, return code 0' '
5656
test_when_finished "rm trace.normal actual expect" &&
57-
GIT_TR2="$(pwd)/trace.normal" test-tool trace2 001return 0 &&
57+
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 0 &&
5858
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual &&
5959
cat >expect <<-EOF &&
6060
version $V
@@ -68,7 +68,7 @@ test_expect_success 'normal stream, return code 0' '
6868

6969
test_expect_success 'normal stream, return code 1' '
7070
test_when_finished "rm trace.normal actual expect" &&
71-
test_must_fail env GIT_TR2="$(pwd)/trace.normal" test-tool trace2 001return 1 &&
71+
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 001return 1 &&
7272
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual &&
7373
cat >expect <<-EOF &&
7474
version $V
@@ -83,7 +83,7 @@ test_expect_success 'normal stream, return code 1' '
8383
test_expect_success 'automatic filename' '
8484
test_when_finished "rm -r traces actual expect" &&
8585
mkdir traces &&
86-
GIT_TR2="$(pwd)/traces" test-tool trace2 001return 0 &&
86+
GIT_TRACE2="$(pwd)/traces" test-tool trace2 001return 0 &&
8787
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <"$(ls traces/*)" >actual &&
8888
cat >expect <<-EOF &&
8989
version $V
@@ -101,7 +101,7 @@ test_expect_success 'automatic filename' '
101101

102102
test_expect_success 'normal stream, exit code 0' '
103103
test_when_finished "rm trace.normal actual expect" &&
104-
GIT_TR2="$(pwd)/trace.normal" test-tool trace2 002exit 0 &&
104+
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 0 &&
105105
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual &&
106106
cat >expect <<-EOF &&
107107
version $V
@@ -115,7 +115,7 @@ test_expect_success 'normal stream, exit code 0' '
115115

116116
test_expect_success 'normal stream, exit code 1' '
117117
test_when_finished "rm trace.normal actual expect" &&
118-
test_must_fail env GIT_TR2="$(pwd)/trace.normal" test-tool trace2 002exit 1 &&
118+
test_must_fail env GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 002exit 1 &&
119119
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual &&
120120
cat >expect <<-EOF &&
121121
version $V
@@ -133,7 +133,7 @@ test_expect_success 'normal stream, exit code 1' '
133133

134134
test_expect_success 'normal stream, error event' '
135135
test_when_finished "rm trace.normal actual expect" &&
136-
GIT_TR2="$(pwd)/trace.normal" test-tool trace2 003error "hello world" "this is a test" &&
136+
GIT_TRACE2="$(pwd)/trace.normal" test-tool trace2 003error "hello world" "this is a test" &&
137137
perl "$TEST_DIRECTORY/t0210/scrub_normal.perl" <trace.normal >actual &&
138138
cat >expect <<-EOF &&
139139
version $V
@@ -147,7 +147,7 @@ test_expect_success 'normal stream, error event' '
147147
test_cmp expect actual
148148
'
149149

150-
sane_unset GIT_TR2_BRIEF
150+
sane_unset GIT_TRACE2_BRIEF
151151

152152
# Now test without environment variables and get all Trace2 settings
153153
# from the global config.

0 commit comments

Comments
 (0)