From c8ba163916554e9ffd3ce8cb2beeff003d90c0c3 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 9 Jun 2011 11:55:23 -0400 Subject: parse-options: add OPT_STRING_LIST helper This just adds repeated invocations of an option to a list of strings. Using the "--no-" form will reset the list to empty. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- parse-options.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'parse-options.c') diff --git a/parse-options.c b/parse-options.c index 73bd28ad9..879ea82a3 100644 --- a/parse-options.c +++ b/parse-options.c @@ -3,6 +3,7 @@ #include "cache.h" #include "commit.h" #include "color.h" +#include "string-list.h" static int parse_options_usage(struct parse_opt_ctx_t *ctx, const char * const *usagestr, @@ -687,3 +688,19 @@ int parse_options_concat(struct option *dst, size_t dst_size, struct option *src } return -1; } + +int parse_opt_string_list(const struct option *opt, const char *arg, int unset) +{ + struct string_list *v = opt->value; + + if (unset) { + string_list_clear(v, 0); + return 0; + } + + if (!arg) + return -1; + + string_list_append(v, xstrdup(arg)); + return 0; +} -- cgit v1.2.1