Skip to content

Commit 3452d17

Browse files
Linus Arvergitster
authored andcommitted
trailer: finish formatting unification
Rename format_trailer_info() to format_trailers(). Finally, both interpret-trailers and format_trailers_from_commit() can call "format_trailers()"! Update the comment in <trailer.h> to remove the (now obsolete) caveats about format_trailers_from_commit(). Those caveats come from a388b10 (pretty: move trailer formatting to trailer.c, 2017-08-15) where it says: pretty: move trailer formatting to trailer.c The next commit will add many features to the %(trailer) placeholder in pretty.c. We'll need to access some internal functions of trailer.c for that, so our options are either: 1. expose those functions publicly or 2. make an entry point into trailer.c to do the formatting Doing (2) ends up exposing less surface area, though do note that caveats in the docstring of the new function. which suggests format_trailers_from_commit() started out from pretty.c and did not have access to all of the trailer implementation internals, and was never intended to replace (unify) the formatting machinery in trailer.c. The refactors leading up to this commit (as well as additional refactors that will follow) expose additional functions publicly, and is therefore choosing option (1) as described in a388b10. Signed-off-by: Linus Arver <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 676c1db commit 3452d17

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

builtin/interpret-trailers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static void interpret_trailers(const struct process_trailer_options *opts,
171171
}
172172

173173
/* Print trailer block. */
174-
format_trailer_info(opts, &head, &trailer_block);
174+
format_trailers(opts, &head, &trailer_block);
175175
free_trailers(&head);
176176
fwrite(trailer_block.buf, 1, trailer_block.len, outfile);
177177
strbuf_release(&trailer_block);

trailer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,9 @@ void trailer_info_release(struct trailer_info *info)
10521052
free(info->trailers);
10531053
}
10541054

1055-
void format_trailer_info(const struct process_trailer_options *opts,
1056-
struct list_head *trailers,
1057-
struct strbuf *out)
1055+
void format_trailers(const struct process_trailer_options *opts,
1056+
struct list_head *trailers,
1057+
struct strbuf *out)
10581058
{
10591059
size_t origlen = out->len;
10601060
struct list_head *pos;
@@ -1128,7 +1128,7 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
11281128
strbuf_add(out, msg + info.trailer_block_start,
11291129
info.trailer_block_end - info.trailer_block_start);
11301130
} else
1131-
format_trailer_info(opts, &trailer_objects, out);
1131+
format_trailers(opts, &trailer_objects, out);
11321132

11331133
free_trailers(&trailer_objects);
11341134
trailer_info_release(&info);

trailer.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,16 @@ void trailer_info_get(const struct process_trailer_options *,
101101
void trailer_info_release(struct trailer_info *info);
102102

103103
void trailer_config_init(void);
104-
void format_trailer_info(const struct process_trailer_options *,
104+
void format_trailers(const struct process_trailer_options *,
105105
struct list_head *trailers,
106106
struct strbuf *out);
107107
void free_trailers(struct list_head *);
108108

109109
/*
110-
* Format the trailers from the commit msg "msg" into the strbuf "out".
111-
* Note two caveats about "opts":
112-
*
113-
* - this is primarily a helper for pretty.c, and not
114-
* all of the flags are supported.
115-
*
116-
* - this differs from process_trailers slightly in that we always format
117-
* only the trailer block itself, even if the "only_trailers" option is not
118-
* set.
110+
* Convenience function to format the trailers from the commit msg "msg" into
111+
* the strbuf "out". Reuses format_trailers() internally.
119112
*/
120-
void format_trailers_from_commit(const struct process_trailer_options *opts,
113+
void format_trailers_from_commit(const struct process_trailer_options *,
121114
const char *msg,
122115
struct strbuf *out);
123116

0 commit comments

Comments
 (0)