Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace2: prefetch value of GIT_TRACE2_DST_DEBUG at startup #663

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions trace2.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ void trace2_initialize_fl(const char *file, int line)
if (!tr2_tgt_want_builtins())
return;
trace2_enabled = 1;

/*
* getenv() on Windows stomps on `errno` and the code in
* tr2_dst.c verifies that warnings are enabled before
* formatting the warning message (and calling strerror()).
* So prefetch the value from the environment before we need
* it.
*/
tr2_dst_want_warning();

if (!git_env_bool("GIT_TRACE2_REDACT", 1))
trace2_redact = 0;

Expand Down
2 changes: 1 addition & 1 deletion trace2/tr2_dst.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
static int tr2env_max_files = 0;

static int tr2_dst_want_warning(void)
int tr2_dst_want_warning(void)
{
static int tr2env_dst_debug = -1;

Expand Down
12 changes: 12 additions & 0 deletions trace2/tr2_dst.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@ int tr2_dst_trace_want(struct tr2_dst *dst);
*/
void tr2_dst_write_line(struct tr2_dst *dst, struct strbuf *buf_line);

/*
* Return true if we want warning messages when trying to open a
* destination.
*
* (Trace2 always silently fails if a target cannot be opened so that
* we don't affect the execution of the Git command, but it is helpful
* for debugging telemetry configuration if we log warning messages
* when trying to open a target. This is controlled by another config
* value.)
*/
int tr2_dst_want_warning(void);

#endif /* TR2_DST_H */
Loading