Skip to content

Commit cf5c934

Browse files
listxgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c1e4b2b commit cf5c934

File tree

2 files changed

+46
-48
lines changed

2 files changed

+46
-48
lines changed

trailer.c

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,52 @@ static struct trailer_info *trailer_info_new(void)
979979
return info;
980980
}
981981

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+
9821028
/*
9831029
* Parse trailers in "str", populating the trailer info and "head"
9841030
* linked list structure.
@@ -1044,52 +1090,6 @@ int blank_line_before_trailer_block(struct trailer_info *info)
10441090
return info->blank_line_before_trailer;
10451091
}
10461092

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-
10931093
void trailer_info_release(struct trailer_info *info)
10941094
{
10951095
size_t i;

trailer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ void process_trailers_lists(struct list_head *head,
7373
struct trailer_info *parse_trailers(const struct process_trailer_options *,
7474
const char *str,
7575
struct list_head *head);
76-
struct trailer_info *trailer_info_get(const struct process_trailer_options *,
77-
const char *str);
7876

7977
size_t trailer_block_start(struct trailer_info *);
8078
size_t trailer_block_end(struct trailer_info *);

0 commit comments

Comments
 (0)