Commit a6192d7c by Carlos Martín Nieto

remote: update head list on push

A previous commit forgot to update the head list after push as well,
leading to wrong output of git_remote_ls().
parent ae297212
......@@ -63,6 +63,24 @@ static int git_smart__set_callbacks(
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,
......@@ -74,7 +92,6 @@ static int git_smart__connect(
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;
......@@ -142,14 +159,7 @@ static int git_smart__connect(
}
/* 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;
......
......@@ -174,6 +174,8 @@ int git_smart__download_pack(
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);
......
......@@ -32,7 +32,6 @@ int git_smart__store_refs(transport_smart *t, int flushes)
/* 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);
......@@ -945,8 +944,13 @@ int git_smart__push(git_transport *transport, git_push *push)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment