return 0;
}
+int git_smart__update_heads(transport_smart *t)
+{
+ size_t i;
+ git_pkt *pkt;
+
+ git_vector_clear(&t->heads);
+ git_vector_foreach(&t->refs, i, pkt) {
+ git_pkt_ref *ref = (git_pkt_ref *) pkt;
+ if (pkt->type != GIT_PKT_REF)
+ continue;
+
+ if (git_vector_insert(&t->heads, &ref->head) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
static int git_smart__connect(
git_transport *transport,
const char *url,
transport_smart *t = (transport_smart *)transport;
git_smart_subtransport_stream *stream;
int error;
- size_t i;
git_pkt *pkt;
git_pkt_ref *first;
git_smart_service_t service;
}
/* Keep a list of heads for _ls */
- git_vector_foreach(&t->refs, i, pkt) {
- git_pkt_ref *ref = (git_pkt_ref *) pkt;
- if (pkt->type != GIT_PKT_REF)
- continue;
-
- if (git_vector_insert(&t->heads, &ref->head) < 0)
- return -1;
- }
+ git_smart__update_heads(t);
if (t->rpc && git_smart__reset_stream(t, false) < 0)
return -1;
int git_smart__negotiation_step(git_transport *transport, void *data, size_t len);
int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **out);
+int git_smart__update_heads(transport_smart *t);
+
/* smart_pkt.c */
int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len);
int git_pkt_buffer_flush(git_buf *buf);
/* Clear existing refs in case git_remote_connect() is called again
* after git_remote_disconnect().
*/
- git_vector_clear(&t->heads);
git_vector_foreach(refs, i, ref) {
git__free(ref->head.name);
git__free(ref);
push->transfer_progress_cb(push->pb->nr_written, push->pb->nr_objects, packbuilder_payload.last_bytes, push->transfer_progress_cb_payload);
}
- if (push->status.length)
+ if (push->status.length) {
error = update_refs_from_report(&t->refs, &push->specs, &push->status);
+ if (error < 0)
+ goto done;
+
+ error = git_smart__update_heads(t);
+ }
done:
git_buf_free(&pktline);