diff mbox series

[v2,05/10] pretty.c: inline initalize format_context

Message ID a2e90c78e64633824000da41fb0b72afb8f1ab52.1573241590.git.liu.denton@gmail.com (mailing list archive)
State New, archived
Headers show
Series learn the "summary" pretty format | expand

Commit Message

Denton Liu Nov. 8, 2019, 8:08 p.m. UTC
Instead of memsetting and then initializing the fields in the struct,
move the initialization of `format_context` to its assignment.

In preparation for a future commit where we mechanically move lines from
repo_format_commit_message() into a helper function,
`format_context.wrap_start` is not generically used so move its
assignment closer to its use.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 pretty.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/pretty.c b/pretty.c
index b32f036953..6f2b0ad917 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1610,14 +1610,13 @@  void repo_format_commit_message(struct repository *r,
 				const char *format, struct strbuf *sb,
 				const struct pretty_print_context *pretty_ctx)
 {
-	struct format_commit_context context;
+	struct format_commit_context context = {
+		.commit = commit,
+		.pretty_ctx = pretty_ctx
+	};
 	const char *output_enc = pretty_ctx->output_encoding;
 	const char *utf8 = "UTF-8";
 
-	memset(&context, 0, sizeof(context));
-	context.commit = commit;
-	context.pretty_ctx = pretty_ctx;
-	context.wrap_start = sb->len;
 	/*
 	 * convert a commit message to UTF-8 first
 	 * as far as 'format_commit_item' assumes it in UTF-8
@@ -1626,6 +1625,7 @@  void repo_format_commit_message(struct repository *r,
 					       &context.commit_encoding,
 					       utf8);
 
+	context.wrap_start = sb->len;
 	strbuf_expand(sb, format, format_commit_item, &context);
 	rewrap_message_tail(sb, &context, 0, 0, 0);