From 676c1db76e310c400b602890ac6853fdf8fdfa98 Mon Sep 17 00:00:00 2001 From: Linus Arver Date: Fri, 15 Mar 2024 06:55:04 +0000 Subject: trailer: begin formatting unification Now that the preparatory refactors are over, we can replace the call to format_trailers() in interpret-trailers with format_trailer_info(). This unifies the trailer formatting machinery In order to avoid breakages in t7502 and t7513, we have to steal the features present in format_trailers(). Namely, we have to teach format_trailer_info() as follows: (1) make it aware of opts->trim_empty, and (2) make it avoid hardcoding ": " as the separator and space (which can result in double-printing these characters). For (2), make it only print the separator and space if we cannot find any recognized separator somewhere in the key (yes, keys may have a trailing separator in it --- we will eventually fix this design but not now). Do so by copying the code out of print_tok_val(), and deleting the same function. Helped-by: Junio C Hamano Helped-by: Christian Couder Signed-off-by: Linus Arver Signed-off-by: Junio C Hamano --- trailer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'trailer.h') diff --git a/trailer.h b/trailer.h index 1d106b6dd4..3c13006a4c 100644 --- a/trailer.h +++ b/trailer.h @@ -101,7 +101,7 @@ void trailer_info_get(const struct process_trailer_options *, void trailer_info_release(struct trailer_info *info); void trailer_config_init(void); -void format_trailers(const struct process_trailer_options *, +void format_trailer_info(const struct process_trailer_options *, struct list_head *trailers, struct strbuf *out); void free_trailers(struct list_head *); -- cgit v1.2.3