Skip to content

Commit 66f66c5

Browse files
kbleesgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b72be02 commit 66f66c5

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

trace.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,20 @@ static void trace_vprintf(struct trace_key *key, const char *format, va_list ap)
132132
print_trace_line(key, &buf);
133133
}
134134

135-
void trace_printf_key(struct trace_key *key, const char *format, ...)
135+
void trace_argv_printf(const char **argv, const char *format, ...)
136136
{
137+
struct strbuf buf = STRBUF_INIT;
137138
va_list ap;
138-
va_start(ap, format);
139-
trace_vprintf(key, format, ap);
140-
va_end(ap);
141-
}
142139

143-
void trace_printf(const char *format, ...)
144-
{
145-
va_list ap;
140+
if (!prepare_trace_line(NULL, &buf))
141+
return;
142+
146143
va_start(ap, format);
147-
trace_vprintf(NULL, format, ap);
144+
strbuf_vaddf(&buf, format, ap);
148145
va_end(ap);
146+
147+
sq_quote_argv(&buf, argv, 0);
148+
print_trace_line(NULL, &buf);
149149
}
150150

151151
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)
159159
print_trace_line(key, &buf);
160160
}
161161

162-
void trace_argv_printf(const char **argv, const char *format, ...)
162+
void trace_printf(const char *format, ...)
163163
{
164-
struct strbuf buf = STRBUF_INIT;
165164
va_list ap;
166-
167-
if (!prepare_trace_line(NULL, &buf))
168-
return;
169-
170165
va_start(ap, format);
171-
strbuf_vaddf(&buf, format, ap);
166+
trace_vprintf(NULL, format, ap);
172167
va_end(ap);
168+
}
173169

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);
176176
}
177177

178178
static const char *quote_crnl(const char *path)

trace.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ struct trace_key {
1313

1414
#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name, 0, 0, 0 }
1515

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, ...);
2016
extern void trace_repo_setup(const char *prefix);
2117
extern int trace_want(struct trace_key *key);
2218
extern void trace_disable(struct trace_key *key);
19+
20+
__attribute__((format (printf, 1, 2)))
21+
extern void trace_printf(const char *format, ...);
22+
2323
__attribute__((format (printf, 2, 3)))
2424
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+
2529
extern void trace_strbuf(struct trace_key *key, const struct strbuf *data);
2630

2731
#endif /* TRACE_H */

0 commit comments

Comments
 (0)