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

Function parse_options_check

parse-options.c:642–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

640}
641
642static void parse_options_check(const struct option *opts)
643{
644 char short_opts[128];
645 bool saw_number_option = false;
646 void *subcommand_value = NULL;
647
648 memset(short_opts, '\0', sizeof(short_opts));
649 for (; opts->type != OPTION_END; opts++) {
650 if ((opts->flags & PARSE_OPT_LASTARG_DEFAULT) &&
651 (opts->flags & PARSE_OPT_OPTARG))
652 optbug(opts, "uses incompatible flags "
653 "LASTARG_DEFAULT and OPTARG");
654 if (opts->short_name) {
655 if (0x7F <= opts->short_name)
656 optbug(opts, "invalid short name");
657 else if (short_opts[opts->short_name]++)
658 optbug(opts, "short name already used");
659 }
660 if (opts->type == OPTION_NUMBER) {
661 if (saw_number_option)
662 optbug(opts, "duplicate numerical option");
663 saw_number_option = true;
664 }
665 if (opts->flags & PARSE_OPT_NODASH &&
666 ((opts->flags & PARSE_OPT_OPTARG) ||
667 !(opts->flags & PARSE_OPT_NOARG) ||
668 !(opts->flags & PARSE_OPT_NONEG) ||
669 opts->long_name))
670 optbug(opts, "uses feature "
671 "not supported for dashless options");
672 if (opts->type == OPTION_SET_INT && !opts->defval &&
673 opts->long_name && !(opts->flags & PARSE_OPT_NONEG))
674 optbug(opts, "OPTION_SET_INT 0 should not be negatable");
675 switch (opts->type) {
676 case OPTION_SET_INT:
677 case OPTION_BIT:
678 case OPTION_NEGBIT:
679 case OPTION_BITOP:
680 case OPTION_COUNTUP:
681 if (!signed_int_fits(opts->defval, opts->precision))
682 optbug(opts, "has invalid defval");
683 /* fallthru */
684 case OPTION_NUMBER:
685 if ((opts->flags & PARSE_OPT_OPTARG) ||
686 !(opts->flags & PARSE_OPT_NOARG))
687 optbug(opts, "should not accept an argument");
688 break;
689 case OPTION_CALLBACK:
690 if (!opts->callback && !opts->ll_callback)
691 optbug(opts, "OPTION_CALLBACK needs one callback");
692 else if (opts->callback && opts->ll_callback)
693 optbug(opts, "OPTION_CALLBACK can't have two callbacks");
694 break;
695 case OPTION_LOWLEVEL_CALLBACK:
696 if (!opts->ll_callback)
697 optbug(opts, "OPTION_LOWLEVEL_CALLBACK needs a callback");
698 if (opts->callback)
699 optbug(opts, "OPTION_LOWLEVEL_CALLBACK needs no high level callback");

Callers 1

parse_options_start_1Function · 0.85

Calls 2

optbugFunction · 0.85
signed_int_fitsFunction · 0.85

Tested by

no test coverage detected