]> git.ipfire.org Git - thirdparty/git.git/commitdiff
trailer: move process_trailers to trailer.h
authorLi Chen <chenl311@chinatelecom.cn>
Wed, 5 Nov 2025 14:29:42 +0000 (22:29 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Nov 2025 17:45:00 +0000 (09:45 -0800)
This function would be used by trailer_process
in following commits.

Signed-off-by: Li Chen <chenl311@chinatelecom.cn>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/interpret-trailers.c
trailer.c
trailer.h

index 4c90580ffffee5cd4f1766f59d3bb84f0bf55cdf..bce2e791d60149454da1a0d54079b4b02a3e79d5 100644 (file)
@@ -136,42 +136,6 @@ static void read_input_file(struct strbuf *sb, const char *file)
        strbuf_complete_line(sb);
 }
 
-static void process_trailers(const struct process_trailer_options *opts,
-                            struct list_head *new_trailer_head,
-                            struct strbuf *sb, struct strbuf *out)
-{
-       LIST_HEAD(head);
-       struct trailer_block *trailer_block;
-
-       trailer_block = parse_trailers(opts, sb->buf, &head);
-
-       /* Print the lines before the trailer block */
-       if (!opts->only_trailers)
-               strbuf_add(out, sb->buf, trailer_block_start(trailer_block));
-
-       if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
-               strbuf_addch(out, '\n');
-
-       if (!opts->only_input) {
-               LIST_HEAD(config_head);
-               LIST_HEAD(arg_head);
-               parse_trailers_from_config(&config_head);
-               parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
-               list_splice(&config_head, &arg_head);
-               process_trailers_lists(&head, &arg_head);
-       }
-
-       /* Print trailer block. */
-       format_trailers(opts, &head, out);
-       free_trailers(&head);
-
-       /* Print the lines after the trailer block as is. */
-       if (!opts->only_trailers)
-               strbuf_add(out, sb->buf + trailer_block_end(trailer_block),
-                          sb->len - trailer_block_end(trailer_block));
-       trailer_block_release(trailer_block);
-}
-
 static void interpret_trailers(const struct process_trailer_options *opts,
                               struct list_head *new_trailer_head,
                               const char *file)
index 911a81ed993ec6aa802bcd0ecbb5a86e3e497d43..b735ec8a5314cd8854a149da538bfd44d29685b2 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -1235,3 +1235,39 @@ int amend_file_with_trailers(const char *path, const struct strvec *trailer_args
        strvec_pushv(&run_trailer.args, trailer_args->v);
        return run_command(&run_trailer);
 }
+
+void process_trailers(const struct process_trailer_options *opts,
+                     struct list_head *new_trailer_head,
+                     struct strbuf *sb, struct strbuf *out)
+{
+       LIST_HEAD(head);
+       struct trailer_block *trailer_block;
+
+       trailer_block = parse_trailers(opts, sb->buf, &head);
+
+       /* Print the lines before the trailer block */
+       if (!opts->only_trailers)
+               strbuf_add(out, sb->buf, trailer_block_start(trailer_block));
+
+       if (!opts->only_trailers && !blank_line_before_trailer_block(trailer_block))
+               strbuf_addch(out, '\n');
+
+       if (!opts->only_input) {
+               LIST_HEAD(config_head);
+               LIST_HEAD(arg_head);
+               parse_trailers_from_config(&config_head);
+               parse_trailers_from_command_line_args(&arg_head, new_trailer_head);
+               list_splice(&config_head, &arg_head);
+               process_trailers_lists(&head, &arg_head);
+       }
+
+       /* Print trailer block. */
+       format_trailers(opts, &head, out);
+       free_trailers(&head);
+
+       /* Print the lines after the trailer block as is. */
+       if (!opts->only_trailers)
+               strbuf_add(out, sb->buf + trailer_block_end(trailer_block),
+                          sb->len - trailer_block_end(trailer_block));
+       trailer_block_release(trailer_block);
+}
index 4740549586a8e5cebdb2a05c18cae11ef86beade..44d406b763d34f3a3ad3d24ad9ae5d931a262d42 100644 (file)
--- a/trailer.h
+++ b/trailer.h
@@ -202,4 +202,7 @@ void trailer_iterator_release(struct trailer_iterator *iter);
  */
 int amend_file_with_trailers(const char *path, const struct strvec *trailer_args);
 
+void process_trailers(const struct process_trailer_options *opts,
+                     struct list_head *new_trailer_head,
+                     struct strbuf *sb, struct strbuf *out);
 #endif /* TRAILER_H */