Skip to content

Commit 3b0c3ab

Browse files
peffgitster
authored andcommitted
trace: correct variable name in write() error message
Our error message for write() always mentions GIT_TRACE, even though we may be writing for a different variable entirely. It's also not quite accurate to say "fd given by GIT_TRACE environment variable", as we may hit this error based on a filename the user put in the variable (we do complain and switch to stderr if the file cannot be opened, but it's still possible to hit a write() error on the descriptor later). So let's fix those things, and switch to our more usual "unable to do X: Y" format for the error. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b3a1c5d commit 3b0c3ab

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

trace.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ void trace_disable(struct trace_key *key)
9393
key->need_close = 0;
9494
}
9595

96-
static const char err_msg[] = "could not trace into fd given by "
97-
"GIT_TRACE environment variable";
98-
9996
static int prepare_trace_line(const char *file, int line,
10097
struct trace_key *key, struct strbuf *buf)
10198
{
@@ -133,8 +130,11 @@ static int prepare_trace_line(const char *file, int line,
133130

134131
static void trace_write(struct trace_key *key, const void *buf, unsigned len)
135132
{
136-
if (write_in_full(get_trace_fd(key), buf, len) < 0)
137-
warning("%s: write error (%s)", err_msg, strerror(errno));
133+
if (write_in_full(get_trace_fd(key), buf, len) < 0) {
134+
normalize_trace_key(&key);
135+
warning("unable to write trace for %s: %s",
136+
key->key, strerror(errno));
137+
}
138138
}
139139

140140
void trace_verbatim(struct trace_key *key, const void *buf, unsigned len)

0 commit comments

Comments
 (0)