зеркало из https://github.com/microsoft/git.git
format_trailer_info(): move "fast path" to caller
This is another preparatory refactor to unify the trailer formatters. This allows us to drop the "msg" parameter from format_trailer_info(), so that it take 3 parameters, similar to format_trailers() which also takes 3 parameters: void format_trailers(const struct process_trailer_options *opts, struct list_head *trailers, struct strbuf *out) The short-term goal is to make format_trailer_info() be smart enough to deprecate format_trailers(). And then ultimately we will rename format_trailer_info() to format_trailers(). Signed-off-by: Linus Arver <linusa@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
bf35e0a018
Коммит
2c948a78fd
20
trailer.c
20
trailer.c
|
@ -1087,21 +1087,11 @@ void trailer_info_release(struct trailer_info *info)
|
|||
|
||||
static void format_trailer_info(const struct process_trailer_options *opts,
|
||||
const struct trailer_info *info,
|
||||
const char *msg,
|
||||
struct strbuf *out)
|
||||
{
|
||||
size_t origlen = out->len;
|
||||
size_t i;
|
||||
|
||||
/* If we want the whole block untouched, we can take the fast path. */
|
||||
if (!opts->only_trailers && !opts->unfold && !opts->filter &&
|
||||
!opts->separator && !opts->key_only && !opts->value_only &&
|
||||
!opts->key_value_separator) {
|
||||
strbuf_add(out, msg + info->trailer_block_start,
|
||||
info->trailer_block_end - info->trailer_block_start);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < info->trailer_nr; i++) {
|
||||
char *trailer = info->trailers[i];
|
||||
ssize_t separator_pos = find_separator(trailer, separators);
|
||||
|
@ -1153,7 +1143,15 @@ void format_trailers_from_commit(const struct process_trailer_options *opts,
|
|||
struct trailer_info info;
|
||||
|
||||
trailer_info_get(opts, msg, &info);
|
||||
format_trailer_info(opts, &info, msg, out);
|
||||
/* If we want the whole block untouched, we can take the fast path. */
|
||||
if (!opts->only_trailers && !opts->unfold && !opts->filter &&
|
||||
!opts->separator && !opts->key_only && !opts->value_only &&
|
||||
!opts->key_value_separator) {
|
||||
strbuf_add(out, msg + info.trailer_block_start,
|
||||
info.trailer_block_end - info.trailer_block_start);
|
||||
} else
|
||||
format_trailer_info(opts, &info, out);
|
||||
|
||||
trailer_info_release(&info);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче