strbuf: separate callback for strbuf_expand:ing literals

Expanding '%n' and '%xNN' is generic functionality, so extract that from
the pretty.c formatter into a callback that can be reused.

No functional change intended

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Anders Waldenborg
2019-01-28 22:33:36 +01:00
committed by Junio C Hamano
parent d9b936db52
commit fd2015b323
3 changed files with 34 additions and 11 deletions

View File

@ -320,6 +320,14 @@ void strbuf_expand(struct strbuf *sb,
expand_fn_t fn,
void *context);
/**
* Used as callback for `strbuf_expand` to only expand literals
* (i.e. %n and %xNN). The context argument is ignored.
*/
size_t strbuf_expand_literal_cb(struct strbuf *sb,
const char *placeholder,
void *context);
/**
* Used as callback for `strbuf_expand()`, expects an array of
* struct strbuf_expand_dict_entry as context, i.e. pairs of