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

Function pipe_command

run-command.c:1429–1484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1427
1428
1429int pipe_command(struct child_process *cmd,
1430 const char *in, size_t in_len,
1431 struct strbuf *out, size_t out_hint,
1432 struct strbuf *err, size_t err_hint)
1433{
1434 struct io_pump io[3];
1435 int nr = 0;
1436
1437 if (in)
1438 cmd->in = -1;
1439 if (out)
1440 cmd->out = -1;
1441 if (err)
1442 cmd->err = -1;
1443
1444 if (start_command(cmd) < 0)
1445 return -1;
1446
1447 if (in) {
1448 if (enable_pipe_nonblock(cmd->in) < 0) {
1449 error_errno("unable to make pipe non-blocking");
1450 close(cmd->in);
1451 if (out)
1452 close(cmd->out);
1453 if (err)
1454 close(cmd->err);
1455 return -1;
1456 }
1457 io[nr].fd = cmd->in;
1458 io[nr].type = POLLOUT;
1459 io[nr].u.out.buf = in;
1460 io[nr].u.out.len = in_len;
1461 nr++;
1462 }
1463 if (out) {
1464 io[nr].fd = cmd->out;
1465 io[nr].type = POLLIN;
1466 io[nr].u.in.buf = out;
1467 io[nr].u.in.hint = out_hint;
1468 nr++;
1469 }
1470 if (err) {
1471 io[nr].fd = cmd->err;
1472 io[nr].type = POLLIN;
1473 io[nr].u.in.buf = err;
1474 io[nr].u.in.hint = err_hint;
1475 nr++;
1476 }
1477
1478 if (pump_io(io, nr) < 0) {
1479 finish_command(cmd); /* throw away exit code */
1480 return -1;
1481 }
1482
1483 return finish_command(cmd);
1484}
1485
1486enum child_state {

Callers 15

grab_describe_valuesFunction · 0.85
capture_commandFunction · 0.85
format_commit_oneFunction · 0.85
remote_default_branchFunction · 0.85
parse_diffFunction · 0.85
run_apply_checkFunction · 0.85
apply_for_checkoutFunction · 0.85
apply_patchFunction · 0.85
verify_gpg_signed_bufferFunction · 0.85
verify_ssh_signed_bufferFunction · 0.85
get_ssh_key_fingerprintFunction · 0.85

Calls 5

start_commandFunction · 0.85
enable_pipe_nonblockFunction · 0.85
error_errnoFunction · 0.85
pump_ioFunction · 0.85
finish_commandFunction · 0.85

Tested by 1

quote_stress_testFunction · 0.68