git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v6 1/6] ref-filter: add shortcut to work with strbufs

From
Olga Telezhnaya <olyatelezhnaya@gmail.com>
Date
Mar 29, 2018, 12:49 UTC
Message-ID
<0102016271ce90fc-1bd75012-add6-49ee-bb32-66eeeb1cc3df-000000@eu-west-1.amazonses.com>
In-Reply-To
<0102016249d21c40-0edf6647-4d26-46fc-8cfd-5a446b93a5e2-000000@eu-west-1.amazonses.com>

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>
---
 ref-filter.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/ref-filter.c b/ref-filter.c
index 45fc56216aaa8..0c8d1589cf316 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)

--
https://github.com/git/git/pull/466
Next: Olga Telezhnaya
Message 1 of 6 in “ref-filter: add shortcut to work with strbufs”
  1. 1/6 ref-filter: add shortcut to work with strbufsOlga Telezhnaya, Mar 29, 2018
  2. 4/6 ref-filter: change parsing function error handlingOlga Telezhnaya, Mar 29, 2018
  3. 2/6 ref-filter: start adding strbufs with errorsOlga Telezhnaya, Mar 29, 2018
  4. 5/6 ref-filter: add return value to parsersOlga Telezhnaya, Mar 29, 2018
  5. 6/6 ref-filter: libify get_ref_atom_value()Olga Telezhnaya, Mar 29, 2018
  6. 3/6 ref-filter: add return value && strbuf to handlersOlga Telezhnaya, Mar 29, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.