]> git.ipfire.org Git - thirdparty/git.git/blobdiff - parse-options-cb.c
checkout: split options[] array in three pieces
[thirdparty/git.git] / parse-options-cb.c
index e2f3eaed072f77d63890ec814d810199f57248d5..caaeed896fbb3d7d05cea0488e96c8b4b1274621 100644 (file)
@@ -122,6 +122,23 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
+struct option *parse_options_dup(const struct option *o)
+{
+       struct option *opts;
+       int nr = 0;
+
+       while (o && o->type != OPTION_END) {
+               nr++;
+               o++;
+       }
+
+       ALLOC_ARRAY(opts, nr + 1);
+       memcpy(opts, o - nr, sizeof(*o) * nr);
+       memset(opts + nr, 0, sizeof(*opts));
+       opts[nr].type = OPTION_END;
+       return opts;
+}
+
 struct option *parse_options_concat(struct option *a, struct option *b)
 {
        struct option *ret;
@@ -170,9 +187,12 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)
  * "-h" output even if it's not being handled directly by
  * parse_options().
  */
-int parse_opt_unknown_cb(const struct option *opt, const char *arg, int unset)
+enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx,
+                                          const struct option *opt,
+                                          const char *arg, int unset)
 {
-       return -2;
+       BUG_ON_OPT_ARG(arg);
+       return PARSE_OPT_UNKNOWN;
 }
 
 /**