@@ -979,6 +979,52 @@ static struct trailer_info *trailer_info_new(void)
979
979
return info ;
980
980
}
981
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
+
982
1028
/*
983
1029
* Parse trailers in "str", populating the trailer info and "head"
984
1030
* linked list structure.
@@ -1044,52 +1090,6 @@ int blank_line_before_trailer_block(struct trailer_info *info)
1044
1090
return info -> blank_line_before_trailer ;
1045
1091
}
1046
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
1093
void trailer_info_release (struct trailer_info * info )
1094
1094
{
1095
1095
size_t i ;
0 commit comments