1
0
mirror of https://github.com/git/git synced 2024-07-02 15:48:44 +00:00

ref-filter: add shortcut to work with strbufs

Add function strbuf_addf_ret() that helps to save a few lines of code.
Function expands fmt with placeholders, append resulting message
to strbuf *sb, and return error code ret.

Signed-off-by: Olga Telezhnaia <olyatelezhnaya@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Olga Telezhnaya 2018-03-29 12:49:45 +00:00 committed by Junio C Hamano
parent 085f5f95a2
commit e2e7a24545

View File

@ -101,6 +101,19 @@ static struct used_atom {
} *used_atom;
static int used_atom_cnt, need_tagged, need_symref;
/*
* Expand string, append it to strbuf *sb, then return error code ret.
* Allow to save few lines of code.
*/
static int strbuf_addf_ret(struct strbuf *sb, int ret, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
strbuf_vaddf(sb, fmt, ap);
va_end(ap);
return ret;
}
static void color_atom_parser(const struct ref_format *format, struct used_atom *atom, const char *color_value)
{
if (!color_value)