MCPcopy Create free account
hub / github.com/git/git / cmd_interpret_trailers

Function cmd_interpret_trailers

builtin/interpret-trailers.c:139–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139int cmd_interpret_trailers(int argc,
140 const char **argv,
141 const char *prefix,
142 struct repository *repo UNUSED)
143{
144 struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT;
145 LIST_HEAD(trailers);
146
147 struct option options[] = {
148 OPT_BOOL(0, "in-place", &opts.in_place, N_("edit files in place")),
149 OPT_BOOL(0, "trim-empty", &opts.trim_empty, N_("trim empty trailers")),
150
151 OPT_CALLBACK(0, "where", &where, N_("placement"),
152 N_("where to place the new trailer"), option_parse_where),
153 OPT_CALLBACK(0, "if-exists", &if_exists, N_("action"),
154 N_("action if trailer already exists"), option_parse_if_exists),
155 OPT_CALLBACK(0, "if-missing", &if_missing, N_("action"),
156 N_("action if trailer is missing"), option_parse_if_missing),
157
158 OPT_BOOL(0, "only-trailers", &opts.only_trailers, N_("output only the trailers")),
159 OPT_BOOL(0, "only-input", &opts.only_input, N_("do not apply trailer.<key-alias> configuration variables")),
160 OPT_BOOL(0, "unfold", &opts.unfold, N_("reformat multiline trailer values as single-line values")),
161 OPT_CALLBACK_F(0, "parse", &opts, NULL, N_("alias for --only-trailers --only-input --unfold"),
162 PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_parse),
163 OPT_BOOL(0, "no-divider", &opts.no_divider, N_("do not treat \"---\" as the end of input")),
164 OPT_CALLBACK(0, "trailer", &trailers, N_("trailer"),
165 N_("trailer(s) to add"), option_parse_trailer),
166 OPT_END()
167 };
168
169 repo_config(the_repository, git_default_config, NULL);
170
171 argc = parse_options(argc, argv, prefix, options,
172 git_interpret_trailers_usage, 0);
173
174 if (opts.only_input && !list_empty(&trailers))
175 usage_msg_opt(
176 _("--trailer with --only-input does not make sense"),
177 git_interpret_trailers_usage,
178 options);
179
180 if (argc) {
181 int i;
182 for (i = 0; i < argc; i++)
183 interpret_trailers(&opts, &trailers, argv[i]);
184 } else {
185 if (opts.in_place)
186 die(_("no input file given for in-place editing"));
187 interpret_trailers(&opts, &trailers, NULL);
188 }
189
190 new_trailers_clear(&trailers);
191
192 return 0;
193}

Callers

nothing calls this directly

Calls 7

parse_optionsFunction · 0.85
list_emptyFunction · 0.85
usage_msg_optFunction · 0.85
interpret_trailersFunction · 0.85
new_trailers_clearFunction · 0.85
repo_configFunction · 0.50
dieFunction · 0.50

Tested by

no test coverage detected