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

Function udt_do_write

transport-helper.c:1464–1484  ·  view source on GitHub ↗

Tries to write data from buffer into destination. If buffer is empty, * no data is written. Returns 0 on success, -1 on error. */

Source from the content-addressed store, hash-verified

1462 * no data is written. Returns 0 on success, -1 on error.
1463 */
1464static int udt_do_write(struct unidirectional_transfer *t)
1465{
1466 ssize_t bytes;
1467
1468 if (t->bufuse == 0)
1469 return 0; /* Nothing to write. */
1470
1471 transfer_debug("%s is writable", t->dest_name);
1472 bytes = xwrite(t->dest, t->buf, t->bufuse);
1473 if (bytes < 0) {
1474 error_errno(_("write(%s) failed"), t->dest_name);
1475 return -1;
1476 } else if (bytes > 0) {
1477 t->bufuse -= bytes;
1478 if (t->bufuse)
1479 memmove(t->buf, t->buf + bytes, t->bufuse);
1480 transfer_debug("Wrote %i bytes to %s (buffer now at %i)",
1481 (int)bytes, t->dest_name, (int)t->bufuse);
1482 }
1483 return 0;
1484}
1485
1486
1487/* State of bidirectional transfer loop. */

Callers 1

udt_copy_task_routineFunction · 0.85

Calls 3

transfer_debugFunction · 0.85
xwriteFunction · 0.85
error_errnoFunction · 0.85

Tested by

no test coverage detected