int git_pkt_buffer_wants(const git_vector *refs, git_transport_caps *caps, git_buf *buf) { unsigned int i = 0; git_remote_head *head; if (caps->common) { for (; i < refs->length; ++i) { head = refs->contents[i]; if (!head->local) break; } if (buffer_want_with_caps(refs->contents[i], caps, buf) < 0) return -1; i++; } for (; i < refs->length; ++i) { char oid[GIT_OID_HEXSZ]; head = refs->contents[i]; if (head->local) continue; git_oid_fmt(oid, &head->oid); git_buf_put(buf, pkt_want_prefix, strlen(pkt_want_prefix)); git_buf_put(buf, oid, GIT_OID_HEXSZ); git_buf_putc(buf, '\n'); if (git_buf_oom(buf)) return -1; } return git_pkt_buffer_flush(buf); }
static int git_close(git_transport *t) { git_buf buf = GIT_BUF_INIT; if (git_pkt_buffer_flush(&buf) < 0) return -1; /* Can't do anything if there's an error, so don't bother checking */ gitno_send(t, buf.ptr, buf.size, 0); git_buf_free(&buf); if (gitno_close(t->socket) < 0) { giterr_set(GITERR_NET, "Failed to close socket"); return -1; } t->connected = 0; #ifdef GIT_WIN32 WSACleanup(); #endif return 0; }