diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-05-20 09:55:26 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-05-21 12:12:32 +0200 |
commit | 306475eb0173d7943a27afee6054af8d0f76bedd (patch) | |
tree | 01940bc9610fe5af6ecb9fced14d0f3d3c4f9f77 /src/transports | |
parent | 8156835df17d89bd7ce1525792aa13146fab551e (diff) | |
download | libgit2-306475eb0173d7943a27afee6054af8d0f76bedd.tar.gz |
remote: expose the remote's symref mappings
Add a symref_target field to git_remote_head to expose the symref
mappings to the user.
Diffstat (limited to 'src/transports')
-rw-r--r-- | src/transports/smart.c | 19 | ||||
-rw-r--r-- | src/transports/smart_pkt.c | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c index 2f3e77726..47ef5038c 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -75,6 +75,25 @@ int git_smart__update_heads(transport_smart *t, git_vector *symrefs) if (pkt->type != GIT_PKT_REF) continue; + if (symrefs) { + git_refspec *spec; + git_buf buf = GIT_BUF_INIT; + size_t j; + int error; + + git_vector_foreach(symrefs, j, spec) { + git_buf_clear(&buf); + if (git_refspec_src_matches(spec, ref->head.name) && + !(error = git_refspec_transform(&buf, spec, ref->head.name))) + ref->head.symref_target = git_buf_detach(&buf); + } + + git_buf_free(&buf); + + if (error < 0) + return error; + } + if (git_vector_insert(&t->heads, &ref->head) < 0) return -1; } diff --git a/src/transports/smart_pkt.c b/src/transports/smart_pkt.c index e9376ae6f..b5f9d6dbe 100644 --- a/src/transports/smart_pkt.c +++ b/src/transports/smart_pkt.c @@ -433,6 +433,7 @@ void git_pkt_free(git_pkt *pkt) if (pkt->type == GIT_PKT_REF) { git_pkt_ref *p = (git_pkt_ref *) pkt; git__free(p->head.name); + git__free(p->head.symref_target); } if (pkt->type == GIT_PKT_OK) { |