trace.c: export trace_setup_key

This is so that we can print traces based on this key outside trace.c. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 30, 2018 at 14:34 UTC cb50761959c0c30aa9c44098db3a72db06570238
2 files changed +8 -7
trace.c
+7 -7
@@ -26,6 +26,7 @@
26
27 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
28 struct trace_key trace_perf_key = TRACE_KEY_INIT(PERFORMANCE);
29 +struct trace_key trace_setup_key = TRACE_KEY_INIT(SETUP);
30
31 /* Get a trace file descriptor from "key" env variable. */
32 static int get_trace_fd(struct trace_key *key)
@@ -300,11 +301,10 @@ static const char *quote_crnl(const char *path)
301 /* FIXME: move prefix to startup_info struct and get rid of this arg */
302 void trace_repo_setup(const char *prefix)
303 {
303 - static struct trace_key key = TRACE_KEY_INIT(SETUP);
304 const char *git_work_tree;
305 char *cwd;
306
307 - if (!trace_want(&key))
307 + if (!trace_want(&trace_setup_key))
308 return;
309
310 cwd = xgetcwd();
@@ -315,11 +315,11 @@ void trace_repo_setup(const char *prefix)
315 if (!prefix)
316 prefix = "(null)";
317
318 - trace_printf_key(&key, "setup: git_dir: %s\n", quote_crnl(get_git_dir()));
319 - trace_printf_key(&key, "setup: git_common_dir: %s\n", quote_crnl(get_git_common_dir()));
320 - trace_printf_key(&key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
321 - trace_printf_key(&key, "setup: cwd: %s\n", quote_crnl(cwd));
322 - trace_printf_key(&key, "setup: prefix: %s\n", quote_crnl(prefix));
318 + trace_printf_key(&trace_setup_key, "setup: git_dir: %s\n", quote_crnl(get_git_dir()));
319 + trace_printf_key(&trace_setup_key, "setup: git_common_dir: %s\n", quote_crnl(get_git_common_dir()));
320 + trace_printf_key(&trace_setup_key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
321 + trace_printf_key(&trace_setup_key, "setup: cwd: %s\n", quote_crnl(cwd));
322 + trace_printf_key(&trace_setup_key, "setup: prefix: %s\n", quote_crnl(prefix));
323
324 free(cwd);
325 }
trace.h
+1
@@ -15,6 +15,7 @@ extern struct trace_key trace_default_key;
15
16 #define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name, 0, 0, 0 }
17 extern struct trace_key trace_perf_key;
18 +extern struct trace_key trace_setup_key;
19
20 extern void trace_repo_setup(const char *prefix);
21 extern int trace_want(struct trace_key *key);