Skip to content

replace strbuf_expand()

René Scharfe git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5pretty: factor out expand_separator()pretty.c+13 -140 replies
2/5strbuf: factor out strbuf_expand_step()builtin/branch.c strbuf.c strbuf.h+24 -255 replies
3/5replace strbuf_expand_dict_cb() with strbuf_expand_step()convert.c ll-merge.c strbuf.c +1 more+28 -563 replies
4/5replace strbuf_expand() with strbuf_expand_step()builtin/cat-file.c builtin/ls-files.c builtin/ls-tree.c +4 more+169 -2723 replies
5/5strbuf: simplify strbuf_expand_literal_cb()builtin/ls-files.c builtin/ls-tree.c pretty.c +2 more+7 -113 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] replace strbuf_expand()

strbuf_expand() is used to interpolate placeholders that start with a percent sign (%) in strings. It invokes a callback function to handle those placeholders, expands "%%" to "%" itself and copies unrecognized placeholders verbatim. Context info for the callback needs to be passed in via a void pointer, e.g. to a custom struct.

There is a better, simpler way: Use a loop to iterate over placeholders and access variables directly, without the need to take a detour through a context struct. This series converts the callers of strbuf_expand() to use the new helper strbuf_expand_step(), removing the overhead that comes with using a callback.

pretty: factor out expand_separator()
strbuf: factor out strbuf_expand_step()
replace strbuf_expand_dict_cb() with strbuf_expand_step() replace strbuf_expand() with strbuf_expand_step()
strbuf: simplify strbuf_expand_literal_cb()

 builtin/branch.c   |  13 +-----
 builtin/cat-file.c |  35 +++++++--------
 builtin/ls-files.c | 109 +++++++++++++++++++--------------------------
 builtin/ls-tree.c  | 107 +++++++++++++++++---------------------------
 convert.c          |  22 +++++----
 daemon.c           |  61 ++++++++-----------------
 ll-merge.c         |  32 +++++++------
 pretty.c           |  99 ++++++++++++++++++++++------------------
 strbuf.c           |  58 +++++-------------------
 strbuf.h           |  57 ++++--------------------
 10 files changed, 228 insertions(+), 365 deletions(-)

--
2.41.0