]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pretty.c: inline initalize format_context
authorDenton Liu <liu.denton@gmail.com>
Wed, 20 Nov 2019 00:51:16 +0000 (16:51 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2019 04:33:36 +0000 (13:33 +0900)
Instead of memsetting and then initializing the fields in the struct,
move the initialization of `format_context` to its assignment.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c

index e4ed14effe1aabdef50155b932a96e6648ff4707..da154affd4c6d48dcc0a00fb20a1616e2b094edd 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1612,14 +1612,14 @@ 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,
+               .wrap_start = sb->len
+       };
        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