]> git.ipfire.org Git - thirdparty/git.git/commitdiff
trailer_info_get(): reorder parameters
authorLinus Arver <linusa@google.com>
Fri, 1 Mar 2024 00:14:43 +0000 (00:14 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Mar 2024 18:35:42 +0000 (10:35 -0800)
This is another preparatory refactor to unify the trailer formatters.

Take

    const struct process_trailer_options *opts

as the first parameter, because these options are required for
parsing trailers (e.g., whether to treat "---" as the end of the log
message). And take

    struct trailer_info *info

last, because it's an "out parameter" (something that the caller wants
to use as the output of this function).

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
trailer.c
trailer.h

index 3cc88d8a8004d91eb2a404214f4ac136a845d61f..8e199fc8a475054a65d0bca4a7ebca78758df3f7 100644 (file)
@@ -332,7 +332,7 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
                sb->buf[sb->len - ignore_footer] = '\0';
        }
 
-       trailer_info_get(&info, sb->buf, &opts);
+       trailer_info_get(&opts, sb->buf, &info);
 
        if (ignore_footer)
                sb->buf[sb->len - ignore_footer] = saved_char;
index 5025be978999d7c95c82a011a157e3a034dd796d..f92d844361ac0d844e5fb68cf3313392adf656b7 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -997,7 +997,7 @@ void parse_trailers(const struct process_trailer_options *opts,
        struct strbuf val = STRBUF_INIT;
        size_t i;
 
-       trailer_info_get(info, str, opts);
+       trailer_info_get(opts, str, info);
 
        for (i = 0; i < info->trailer_nr; i++) {
                int separator_pos;
@@ -1032,8 +1032,9 @@ void free_trailers(struct list_head *trailers)
        }
 }
 
-void trailer_info_get(struct trailer_info *info, const char *str,
-                     const struct process_trailer_options *opts)
+void trailer_info_get(const struct process_trailer_options *opts,
+                     const char *str,
+                     struct trailer_info *info)
 {
        size_t end_of_log_message = 0, trailer_block_start = 0;
        struct strbuf **trailer_lines, **ptr;
@@ -1150,7 +1151,7 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
 {
        struct trailer_info info;
 
-       trailer_info_get(&info, msg, opts);
+       trailer_info_get(opts, msg, &info);
        format_trailer_info(opts, &info, msg, out);
        trailer_info_release(&info);
 }
@@ -1161,7 +1162,7 @@ void trailer_iterator_init(struct trailer_iterator *iter, const char *msg)
        strbuf_init(&iter->key, 0);
        strbuf_init(&iter->val, 0);
        opts.no_divider = 1;
-       trailer_info_get(&iter->internal.info, msg, &opts);
+       trailer_info_get(&opts, msg, &iter->internal.info);
        iter->internal.cur = 0;
 }
 
index c6d3ee49bbf76988aef57eefee8c15a9ac1aa32a..410c61b62befa3d5f70146c0dccb0d0ec6c494de 100644 (file)
--- a/trailer.h
+++ b/trailer.h
@@ -94,8 +94,9 @@ void parse_trailers(const struct process_trailer_options *,
                    const char *str,
                    struct list_head *head);
 
-void trailer_info_get(struct trailer_info *info, const char *str,
-                     const struct process_trailer_options *opts);
+void trailer_info_get(const struct process_trailer_options *,
+                     const char *str,
+                     struct trailer_info *);
 
 void trailer_info_release(struct trailer_info *info);