MCPcopy Index your code
hub / github.com/git/git / parse_options_start_1

Function parse_options_start_1

parse-options.c:746–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744}
745
746static void parse_options_start_1(struct parse_opt_ctx_t *ctx,
747 int argc, const char **argv, const char *prefix,
748 const struct option *options,
749 enum parse_opt_flags flags)
750{
751 ctx->argc = argc;
752 ctx->argv = argv;
753 if (!(flags & PARSE_OPT_ONE_SHOT)) {
754 ctx->argc--;
755 ctx->argv++;
756 }
757 ctx->total = ctx->argc;
758 ctx->out = argv;
759 ctx->prefix = prefix;
760 ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
761 ctx->flags = flags;
762 ctx->has_subcommands = has_subcommands(options);
763 if (!ctx->has_subcommands && (flags & PARSE_OPT_SUBCOMMAND_OPTIONAL))
764 BUG("Using PARSE_OPT_SUBCOMMAND_OPTIONAL without subcommands");
765 if (ctx->has_subcommands) {
766 if (flags & PARSE_OPT_STOP_AT_NON_OPTION)
767 BUG("subcommands are incompatible with PARSE_OPT_STOP_AT_NON_OPTION");
768 if (!(flags & PARSE_OPT_SUBCOMMAND_OPTIONAL)) {
769 if (flags & PARSE_OPT_KEEP_UNKNOWN_OPT)
770 BUG("subcommands are incompatible with PARSE_OPT_KEEP_UNKNOWN_OPT unless in combination with PARSE_OPT_SUBCOMMAND_OPTIONAL");
771 if (flags & PARSE_OPT_KEEP_DASHDASH)
772 BUG("subcommands are incompatible with PARSE_OPT_KEEP_DASHDASH unless in combination with PARSE_OPT_SUBCOMMAND_OPTIONAL");
773 }
774 }
775 if ((flags & PARSE_OPT_KEEP_UNKNOWN_OPT) &&
776 (flags & PARSE_OPT_STOP_AT_NON_OPTION) &&
777 !(flags & PARSE_OPT_ONE_SHOT))
778 BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
779 if ((flags & PARSE_OPT_ONE_SHOT) &&
780 (flags & PARSE_OPT_KEEP_ARGV0))
781 BUG("Can't keep argv0 if you don't have it");
782 parse_options_check(options);
783 build_cmdmode_list(ctx, options);
784}
785
786void parse_options_start(struct parse_opt_ctx_t *ctx,
787 int argc, const char **argv, const char *prefix,

Callers 2

parse_options_startFunction · 0.85
parse_optionsFunction · 0.85

Calls 3

has_subcommandsFunction · 0.85
parse_options_checkFunction · 0.85
build_cmdmode_listFunction · 0.85

Tested by

no test coverage detected