summaryrefslogtreecommitdiff
path: root/src/remote.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-08-06 13:48:52 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-18 02:34:08 +0200
commit441f57c2b7fe414ed50b2d13979795a69bd7bd59 (patch)
tree69ae8ac851a9dd03f7847b0cf8ec88ad5b794534 /src/remote.c
parentc1af5a3935025f486156cdfe3b006700e73f0a49 (diff)
downloadlibgit2-441f57c2b7fe414ed50b2d13979795a69bd7bd59.tar.gz
Add git_remote_update_tips
This function updates the references in the local reference storage to match the ones in the remote. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/remote.c')
-rw-r--r--src/remote.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c
index 75f2dc700..618e8f083 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -31,6 +31,7 @@
#include "repository.h"
#include "remote.h"
#include "fetch.h"
+#include "refs.h"
static int refspec_parse(git_refspec *refspec, const char *str)
{
@@ -218,6 +219,32 @@ git_headarray *git_remote_tips(git_remote *remote)
return &remote->refs;
}
+int git_remote_update_tips(struct git_remote *remote)
+{
+ int error = GIT_SUCCESS;
+ unsigned int i;
+ char refname[GIT_PATH_MAX];
+ git_headarray *refs = &remote->refs;
+ git_remote_head *head;
+ git_reference *ref;
+ struct git_refspec *spec = &remote->fetch;
+
+ memset(refname, 0x0, sizeof(refname));
+
+ for (i = 0; i < refs->len; ++i) {
+ head = refs->heads[i];
+ error = git_refspec_transform(refname, sizeof(refname), spec, head->name);
+ if (error < GIT_SUCCESS)
+ return error;
+
+ error = git_reference_create_oid(&ref, remote->repo, refname, &head->oid, 1);
+ if (error < GIT_SUCCESS)
+ return error;
+ }
+
+ return GIT_SUCCESS;
+}
+
void git_remote_free(git_remote *remote)
{
free(remote->fetch.src);