Code

Merge branch 'jc/maint-combined-diff-work-tree'
[git.git] / parse-options.c
index 42b51ef14514f3c3df454e4b718718a9b58f1612..879ea82a3158ca5e6d4ca397e0c2dd2265e15edc 100644 (file)
@@ -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,
@@ -561,14 +562,14 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
        return PARSE_OPT_HELP;
 }
 
-void usage_with_options(const char * const *usagestr,
+void NORETURN usage_with_options(const char * const *usagestr,
                        const struct option *opts)
 {
        usage_with_options_internal(NULL, usagestr, opts, 0, 1);
        exit(129);
 }
 
-void usage_msg_opt(const char *msg,
+void NORETURN usage_msg_opt(const char *msg,
                   const char * const *usagestr,
                   const struct option *options)
 {
@@ -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;
+}