trace: move code around, in preparation to file:line output
No functional changes, just move stuff around so that the next patch isn't that ugly... Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karsten Blees committed
Jul 12, 2014 at 02:04 UTC
66f66c596fa2b4e7d4c00575a5731d33ab28d4ed
2 files changed
+26
-22
trace.c
+18
-18
@@ -132,20 +132,20 @@ static void trace_vprintf(struct trace_key *key, const char *format, va_list ap)
132
print_trace_line(key, &buf);
133
}
134
135
-void trace_printf_key(struct trace_key *key, const char *format, ...)
135
+void trace_argv_printf(const char **argv, const char *format, ...)
136
{
137
+ struct strbuf buf = STRBUF_INIT;
138
va_list ap;
138
- va_start(ap, format);
139
- trace_vprintf(key, format, ap);
140
- va_end(ap);
141
-}
139
143
-void trace_printf(const char *format, ...)
144
-{
145
- va_list ap;
140
+ if (!prepare_trace_line(NULL, &buf))
141
+ return;
142
+
143
va_start(ap, format);
147
- trace_vprintf(NULL, format, ap);
144
+ strbuf_vaddf(&buf, format, ap);
145
va_end(ap);
146
+
147
+ sq_quote_argv(&buf, argv, 0);
148
+ print_trace_line(NULL, &buf);
149
}
150
151
void trace_strbuf(struct trace_key *key, const struct strbuf *data)
@@ -159,20 +159,20 @@ void trace_strbuf(struct trace_key *key, const struct strbuf *data)
159
print_trace_line(key, &buf);
160
}
161
162
-void trace_argv_printf(const char **argv, const char *format, ...)
162
+void trace_printf(const char *format, ...)
163
{
164
- struct strbuf buf = STRBUF_INIT;
164
va_list ap;
166
-
167
- if (!prepare_trace_line(NULL, &buf))
168
- return;
169
-
165
va_start(ap, format);
171
- strbuf_vaddf(&buf, format, ap);
166
+ trace_vprintf(NULL, format, ap);
167
va_end(ap);
168
+}
169
174
- sq_quote_argv(&buf, argv, 0);
175
- print_trace_line(NULL, &buf);
170
+void trace_printf_key(struct trace_key *key, const char *format, ...)
171
+{
172
+ va_list ap;
173
+ va_start(ap, format);
174
+ trace_vprintf(key, format, ap);
175
+ va_end(ap);
176
}
177
178
static const char *quote_crnl(const char *path)
trace.h
+8
-4
@@ -13,15 +13,19 @@ struct trace_key {
13
14
#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name, 0, 0, 0 }
15
16
-__attribute__((format (printf, 1, 2)))
17
-extern void trace_printf(const char *format, ...);
18
-__attribute__((format (printf, 2, 3)))
19
-extern void trace_argv_printf(const char **argv, const char *format, ...);
16
extern void trace_repo_setup(const char *prefix);
17
extern int trace_want(struct trace_key *key);
18
extern void trace_disable(struct trace_key *key);
19
+
20
+__attribute__((format (printf, 1, 2)))
21
+extern void trace_printf(const char *format, ...);
22
+
23
__attribute__((format (printf, 2, 3)))
24
extern void trace_printf_key(struct trace_key *key, const char *format, ...);
25
+
26
+__attribute__((format (printf, 2, 3)))
27
+extern void trace_argv_printf(const char **argv, const char *format, ...);
28
+
29
extern void trace_strbuf(struct trace_key *key, const struct strbuf *data);
30
31
#endif /* TRACE_H */