microsoft / git

A fork of Git containing Microsoft-specific patches.
http://git-scm.com/
Other
782 stars 92 forks source link

trace2: prefetch value of GIT_TRACE2_DST_DEBUG at startup #663

Closed jeffhostetler closed 4 months ago

jeffhostetler commented 4 months ago

Prefetch the value of GIT_TRACE2_DST_DEBUG during startup and before we try to open any Trace2 destination pathnames.

Normally, Trace2 always silently fails if a destination target cannot be opened so that it doesn't affect the execution of a Git command. The command should run normally, but just not generate any trace data. This can make it difficult to debug a telemetry setup, since the user doesn't know why telemetry isn't being generated. If the environment variable GIT_TRACE2_DST_DEBUG is true, the Trace2 startup will print a warning message with the errno to make debugging easier.

However, on Windows, looking up the env variable resets errno so the warning message always ends with ...tracing: No error which is not very helpful.

Prefetch the env variable at startup. This avoids the need to update each call-site to capture errno in the usual saved-errno variable.

jeffhostetler commented 4 months ago

I know this could go upstream or GFW at least, but I'm running out of time and wanted to clear out my backlog if I could.