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

Function show_gitcomp

parse-options.c:844–892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

842}
843
844static int show_gitcomp(const struct option *opts, int show_all)
845{
846 const struct option *original_opts = opts;
847 int nr_noopts = 0;
848
849 for (; opts->type != OPTION_END; opts++) {
850 const char *prefix = "--";
851 const char *suffix = "";
852
853 if (!opts->long_name)
854 continue;
855 if (!show_all &&
856 (opts->flags & (PARSE_OPT_HIDDEN | PARSE_OPT_NOCOMPLETE | PARSE_OPT_FROM_ALIAS)))
857 continue;
858
859 switch (opts->type) {
860 case OPTION_SUBCOMMAND:
861 prefix = "";
862 break;
863 case OPTION_GROUP:
864 continue;
865 case OPTION_STRING:
866 case OPTION_FILENAME:
867 case OPTION_INTEGER:
868 case OPTION_UNSIGNED:
869 case OPTION_CALLBACK:
870 if (opts->flags & PARSE_OPT_NOARG)
871 break;
872 if (opts->flags & PARSE_OPT_OPTARG)
873 break;
874 if (opts->flags & PARSE_OPT_LASTARG_DEFAULT)
875 break;
876 suffix = "=";
877 break;
878 default:
879 break;
880 }
881 if (opts->flags & PARSE_OPT_COMP_ARG)
882 suffix = "=";
883 if (starts_with(opts->long_name, "no-"))
884 nr_noopts++;
885 printf("%s%s%s%s", opts == original_opts ? "" : " ",
886 prefix, opts->long_name, suffix);
887 }
888 show_negated_gitcomp(original_opts, show_all, -1);
889 show_negated_gitcomp(original_opts, show_all, nr_noopts);
890 fputc('\n', stdout);
891 return PARSE_OPT_COMPLETE;
892}
893
894/*
895 * Scan and may produce a new option[] array, which should be used

Callers 1

parse_options_stepFunction · 0.85

Calls 2

starts_withFunction · 0.85
show_negated_gitcompFunction · 0.85

Tested by

no test coverage detected