diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-12-28 14:28:43 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-30 22:05:28 +0100 |
commit | fa476be8f0963d4dd512eaf8ee23b3cd3986a500 (patch) | |
tree | 07cc46c2a071ee0f0b4354920494227054af0666 /parse-options.c | |
parent | cat-file tests: test messaging on bad objects/paths (diff) | |
download | git-fa476be8f0963d4dd512eaf8ee23b3cd3986a500.tar.xz git-fa476be8f0963d4dd512eaf8ee23b3cd3986a500.zip |
parse-options API: add a usage_msg_optf()
Add a usage_msg_optf() as a shorthand for the sort of
usage_msg_opt(xstrfmt(...)) used in builtin/stash.c. I'll make more
use of this function in builtin/cat-file.c shortly.
The disconnect between the "..." and "fmt" is a bit unusual, but it
works just fine and this keeps it consistent with usage_msg_opt(),
i.e. a caller of it can be moved to usage_msg_optf() and not have to
have its arguments re-arranged.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r-- | parse-options.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c index fc5b43ff0b..5a319dda7d 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1078,3 +1078,16 @@ void NORETURN usage_msg_opt(const char *msg, fprintf(stderr, "fatal: %s\n\n", msg); usage_with_options(usagestr, options); } + +void NORETURN usage_msg_optf(const char * const fmt, + const char * const *usagestr, + const struct option *options, ...) +{ + struct strbuf msg = STRBUF_INIT; + va_list ap; + va_start(ap, options); + strbuf_vaddf(&msg, fmt, ap); + va_end(ap); + + usage_msg_opt(msg.buf, usagestr, options); +} |