parse-options: add OPT_STRING_LIST helper
This just adds repeated invocations of an option to a list of strings. Using the "--no-<var>" form will reset the list to empty. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
f77bccaeba
commit
c8ba163916
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user