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

Function apply_command

trailer.c:218–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218static char *apply_command(struct conf_info *conf, const char *arg)
219{
220 struct strbuf cmd = STRBUF_INIT;
221 struct strbuf buf = STRBUF_INIT;
222 struct child_process cp = CHILD_PROCESS_INIT;
223 char *result;
224
225 if (conf->cmd) {
226 strbuf_addstr(&cmd, conf->cmd);
227 strvec_push(&cp.args, cmd.buf);
228 if (arg)
229 strvec_push(&cp.args, arg);
230 } else if (conf->command) {
231 strbuf_addstr(&cmd, conf->command);
232 if (arg)
233 strbuf_replace(&cmd, TRAILER_ARG_STRING, arg);
234 strvec_push(&cp.args, cmd.buf);
235 }
236 strvec_pushv(&cp.env, (const char **)local_repo_env);
237 cp.no_stdin = 1;
238 cp.use_shell = 1;
239
240 if (capture_command(&cp, &buf, 1024)) {
241 error(_("running trailer command '%s' failed"), cmd.buf);
242 strbuf_release(&buf);
243 result = xstrdup("");
244 } else {
245 strbuf_trim(&buf);
246 result = strbuf_detach(&buf, NULL);
247 }
248
249 strbuf_release(&cmd);
250 return result;
251}
252
253static void apply_item_command(struct trailer_item *in_tok, struct arg_item *arg_tok)
254{

Callers 1

apply_item_commandFunction · 0.85

Calls 10

strbuf_addstrFunction · 0.85
strvec_pushFunction · 0.85
strbuf_replaceFunction · 0.85
strvec_pushvFunction · 0.85
capture_commandFunction · 0.85
errorFunction · 0.85
strbuf_releaseFunction · 0.85
xstrdupFunction · 0.85
strbuf_trimFunction · 0.85
strbuf_detachFunction · 0.85

Tested by

no test coverage detected