trailer: retire trailer_info_get() from API
Make trailer_info_get() "static" to be file-scoped to trailer.c, because no one outside of trailer.c uses it. Remove its declaration from <trailer.h>. We have to also reposition it to be above parse_trailers(), which depends on it. Signed-off-by: Linus Arver <linus@ucla.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Linus Arver committed
May 2, 2024 at 04:54 UTC
cf5c9349de52d8d5fa02f7a5b6d9122260834f26
2 files changed
+46
-48
trailer.c
+46
-46
@@ -979,6 +979,52 @@ static struct trailer_info *trailer_info_new(void)
979
return info;
980
}
981
982
+static struct trailer_info *trailer_info_get(const struct process_trailer_options *opts,
983
+ const char *str)
984
+{
985
+ struct trailer_info *info = trailer_info_new();
986
+ size_t end_of_log_message = 0, trailer_block_start = 0;
987
+ struct strbuf **trailer_lines, **ptr;
988
+ char **trailer_strings = NULL;
989
+ size_t nr = 0, alloc = 0;
990
+ char **last = NULL;
991
+
992
+ trailer_config_init();
993
+
994
+ end_of_log_message = find_end_of_log_message(str, opts->no_divider);
995
+ trailer_block_start = find_trailer_block_start(str, end_of_log_message);
996
+
997
+ trailer_lines = strbuf_split_buf(str + trailer_block_start,
998
+ end_of_log_message - trailer_block_start,
999
+ '\n',
1000
+ 0);
1001
+ for (ptr = trailer_lines; *ptr; ptr++) {
1002
+ if (last && isspace((*ptr)->buf[0])) {
1003
+ struct strbuf sb = STRBUF_INIT;
1004
+ strbuf_attach(&sb, *last, strlen(*last), strlen(*last));
1005
+ strbuf_addbuf(&sb, *ptr);
1006
+ *last = strbuf_detach(&sb, NULL);
1007
+ continue;
1008
+ }
1009
+ ALLOC_GROW(trailer_strings, nr + 1, alloc);
1010
+ trailer_strings[nr] = strbuf_detach(*ptr, NULL);
1011
+ last = find_separator(trailer_strings[nr], separators) >= 1
1012
+ ? &trailer_strings[nr]
1013
+ : NULL;
1014
+ nr++;
1015
+ }
1016
+ strbuf_list_free(trailer_lines);
1017
+
1018
+ info->blank_line_before_trailer = ends_with_blank_line(str,
1019
+ trailer_block_start);
1020
+ info->trailer_block_start = trailer_block_start;
1021
+ info->trailer_block_end = end_of_log_message;
1022
+ info->trailers = trailer_strings;
1023
+ info->trailer_nr = nr;
1024
+
1025
+ return info;
1026
+}
1027
+
1028
/*
1029
* Parse trailers in "str", populating the trailer info and "head"
1030
* linked list structure.
@@ -1044,52 +1090,6 @@ int blank_line_before_trailer_block(struct trailer_info *info)
1090
return info->blank_line_before_trailer;
1091
}
1092
1047
-struct trailer_info *trailer_info_get(const struct process_trailer_options *opts,
1048
- const char *str)
1049
-{
1050
- struct trailer_info *info = trailer_info_new();
1051
- size_t end_of_log_message = 0, trailer_block_start = 0;
1052
- struct strbuf **trailer_lines, **ptr;
1053
- char **trailer_strings = NULL;
1054
- size_t nr = 0, alloc = 0;
1055
- char **last = NULL;
1056
-
1057
- trailer_config_init();
1058
-
1059
- end_of_log_message = find_end_of_log_message(str, opts->no_divider);
1060
- trailer_block_start = find_trailer_block_start(str, end_of_log_message);
1061
-
1062
- trailer_lines = strbuf_split_buf(str + trailer_block_start,
1063
- end_of_log_message - trailer_block_start,
1064
- '\n',
1065
- 0);
1066
- for (ptr = trailer_lines; *ptr; ptr++) {
1067
- if (last && isspace((*ptr)->buf[0])) {
1068
- struct strbuf sb = STRBUF_INIT;
1069
- strbuf_attach(&sb, *last, strlen(*last), strlen(*last));
1070
- strbuf_addbuf(&sb, *ptr);
1071
- *last = strbuf_detach(&sb, NULL);
1072
- continue;
1073
- }
1074
- ALLOC_GROW(trailer_strings, nr + 1, alloc);
1075
- trailer_strings[nr] = strbuf_detach(*ptr, NULL);
1076
- last = find_separator(trailer_strings[nr], separators) >= 1
1077
- ? &trailer_strings[nr]
1078
- : NULL;
1079
- nr++;
1080
- }
1081
- strbuf_list_free(trailer_lines);
1082
-
1083
- info->blank_line_before_trailer = ends_with_blank_line(str,
1084
- trailer_block_start);
1085
- info->trailer_block_start = trailer_block_start;
1086
- info->trailer_block_end = end_of_log_message;
1087
- info->trailers = trailer_strings;
1088
- info->trailer_nr = nr;
1089
-
1090
- return info;
1091
-}
1092
-
1093
void trailer_info_release(struct trailer_info *info)
1094
{
1095
size_t i;
trailer.h
-2
@@ -73,8 +73,6 @@ void process_trailers_lists(struct list_head *head,
73
struct trailer_info *parse_trailers(const struct process_trailer_options *,
74
const char *str,
75
struct list_head *head);
76
-struct trailer_info *trailer_info_get(const struct process_trailer_options *,
77
- const char *str);
76
77
size_t trailer_block_start(struct trailer_info *);
78
size_t trailer_block_end(struct trailer_info *);