aboutsummaryrefslogtreecommitdiffstats
path: root/log-tree.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-03-19 20:35:33 -0400
committerJunio C Hamano <gitster@pobox.com>2024-03-19 17:54:16 -0700
commit305a68143cc0e9b714d71417efa9f0162dd07221 (patch)
tree0ccc59a20ce1c784df5d6f2c3c1be90b5784c7c8 /log-tree.h
parent82363d967042ca2884b087b0895bbc566704388e (diff)
downloadgit-305a68143cc0e9b714d71417efa9f0162dd07221.tar.gz
format-patch: return an allocated string from log_write_email_headers()
When pretty-printing a commit in the email format, we have to fill in the "after subject" field of the pretty_print_context with any extra headers the user provided (e.g., from "--to" or "--cc" options) plus any special MIME headers. We return an out-pointer that sometimes points to a newly heap-allocated string and sometimes not. To avoid leaking, we store the allocated version in a buffer with static lifetime, which is ugly. Worse, as we extend the header feature, we'll end up having to repeat this ugly pattern. Instead, let's have our out-pointer pass ownership back to the caller, and duplicate the string when necessary. This does mean one extra allocation per commit when you use extra headers, but in the context of format-patch which is showing diffs, I don't think that's even measurable. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.h')
-rw-r--r--log-tree.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/log-tree.h b/log-tree.h
index 41c776fea5..94978e2c83 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -29,7 +29,7 @@ void format_decorations(struct strbuf *sb, const struct commit *commit,
int use_color, const struct decoration_options *opts);
void show_decorations(struct rev_info *opt, struct commit *commit);
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
- const char **extra_headers_p,
+ char **extra_headers_p,
int *need_8bit_cte_p,
int maybe_multipart);
void load_ref_decorations(struct decoration_filter *filter, int flags);