Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlga Telezhnaya <olyatelezhnaya@gmail.com>2018-03-29 15:49:45 +0300
committerJunio C Hamano <gitster@pobox.com>2018-03-30 00:24:47 +0300
commite2e7a245459391a06a11b70282177135b3fe111c (patch)
tree25d602d5be599b26541ecf7498a464b56d722c20 /ref-filter.c
parent085f5f95a2723e8f9f4d037c01db5b786355ba49 (diff)
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>
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ref-filter.c b/ref-filter.c
index 45fc56216a..0c8d1589cf 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -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)