summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0679660)
raw | patch | inline | side by side (parent: 0679660)
author | Jeff King <peff@peff.net> | |
Thu, 24 Feb 2011 14:28:59 +0000 (09:28 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 8 Mar 2011 20:12:04 +0000 (12:12 -0800) |
As we add more tracing areas, this will avoid repeated code.
Technically, trace_printf already checks this and will avoid
printing if the trace key is not set. However, callers may
want to find out early whether or not tracing is enabled so
they can avoid doing work in the common non-trace case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Technically, trace_printf already checks this and will avoid
printing if the trace key is not set. However, callers may
want to find out early whether or not tracing is enabled so
they can avoid doing work in the common non-trace case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
trace.c | patch | blob | history |
index 2ab1bf9383994e826777da8b4c3fe7a960d6c509..211d7bb26ec2499bb5f2a5733b61e0963f17b1fb 100644 (file)
--- a/cache.h
+++ b/cache.h
__attribute__((format (printf, 2, 3)))
extern void trace_argv_printf(const char **argv, const char *format, ...);
extern void trace_repo_setup(const char *prefix);
+extern int trace_want(const char *key);
/* convert.c */
/* returns 1 if *dst was used */
index 1d0e17e014a5268f76e1c13de2311b27866bc6a9..ca0ab0448bd3981e740e99e14935670cae729ede 100644 (file)
--- a/trace.c
+++ b/trace.c
{
const char *git_work_tree;
char cwd[PATH_MAX];
- char *trace = getenv("GIT_TRACE");
- if (!trace || !strcmp(trace, "") ||
- !strcmp(trace, "0") || !strcasecmp(trace, "false"))
+ if (!trace_want("GIT_TRACE"))
return;
if (!getcwd(cwd, PATH_MAX))
trace_printf("setup: cwd: %s\n", quote_crnl(cwd));
trace_printf("setup: prefix: %s\n", quote_crnl(prefix));
}
+
+int trace_want(const char *key)
+{
+ const char *trace = getenv(key);
+
+ if (!trace || !strcmp(trace, "") ||
+ !strcmp(trace, "0") || !strcasecmp(trace, "false"))
+ return 0;
+ return 1;
+}