aboutsummaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-06-09 11:55:23 -0400
committerJunio C Hamano <gitster@pobox.com>2011-06-22 11:25:20 -0700
commitc8ba163916554e9ffd3ce8cb2beeff003d90c0c3 (patch)
treeae035aa6494b6b852d3ddf4e2989a35900a6f0dc /parse-options.c
parentf77bccaeba7a4c542e9b89d144af74bddd36fd08 (diff)
downloadgit-c8ba163916554e9ffd3ce8cb2beeff003d90c0c3.tar.gz
git-c8ba163916554e9ffd3ce8cb2beeff003d90c0c3.tar.xz
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>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c17
1 files changed, 17 insertions, 0 deletions
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;
+}