pretty: single return path in %(trailers) handling
authorAnders Waldenborg <anders@0x63.nu>
Mon, 28 Jan 2019 21:33:33 +0000 (22:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Jan 2019 18:03:32 +0000 (10:03 -0800)
No functional change intended.

This change may not seem useful on its own, but upcoming commits will do
memory allocation in there, and a single return path makes deallocation
easier.

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c
index 4dfbd38cf643bdf0be8ab856ca8d5e3029bbdd2b..610837e43949f7587433fab50c932c48bfa9ae3f 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1353,6 +1353,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
 
        if (skip_prefix(placeholder, "(trailers", &arg)) {
                struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT;
+               size_t ret = 0;
 
                opts.no_divider = 1;
 
@@ -1366,8 +1367,9 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
                }
                if (*arg == ')') {
                        format_trailers_from_commit(sb, msg + c->subject_off, &opts);
-                       return arg - placeholder + 1;
+                       ret = arg - placeholder + 1;
                }
+               return ret;
        }
 
        return 0;       /* unknown placeholder */