summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-12-21 16:36:34 +0100
committernulltoken <emeric.fermas@gmail.com>2011-12-21 21:30:12 +0100
commitdb1f7e596c072380ec994ae2e71556fc0a6568f7 (patch)
tree5eb617e28bfc7f6aab0b26dd6e1dd0de79f7c891 /src
parent1bdba3386d9953c722d9302f414156104cc06945 (diff)
downloadlibgit2-db1f7e596c072380ec994ae2e71556fc0a6568f7.tar.gz
remote: add test to retrieve the advertised references from a local repository and fix related implementation
Diffstat (limited to 'src')
-rw-r--r--src/transports/local.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/transports/local.c b/src/transports/local.c
index 6cf0573e8..c433339a7 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -46,14 +46,12 @@ static int add_ref(transport_local *t, const char *name)
if (error < GIT_SUCCESS)
goto out;
- git_oid_cpy(&head->oid, git_reference_oid(ref));
+ git_oid_cpy(&head->oid, git_reference_oid(resolved_ref));
error = git_vector_insert(&t->refs, head);
if (error < GIT_SUCCESS)
goto out;
- head = NULL;
-
/* If it's not a tag, we don't need to try to peel it */
if (git__prefixcmp(name, GIT_REFS_TAGS_DIR))
goto out;
@@ -63,6 +61,8 @@ static int add_ref(transport_local *t, const char *name)
git__rethrow(error, "Failed to lookup object");
}
+ head = NULL;
+
/* If it's not an annotated tag, just get out */
if (git_object_type(obj) != GIT_OBJ_TAG)
goto out;
@@ -163,20 +163,30 @@ static int local_connect(git_transport *transport, int GIT_UNUSED(direction))
GIT_UNUSED_ARG(direction);
/* The repo layer doesn't want the prefix */
- if (!git__prefixcmp(transport->url, file_prefix))
- path = transport->url + strlen(file_prefix);
- else
+ if (!git__prefixcmp(transport->url, "file://")) {
+ path = transport->url + strlen("file://");
+
+#ifdef _MSC_VER
+ /* skip the leading slash on windows before the drive letter */
+ if (*path != '/')
+ return git__throw(GIT_EINVALIDPATH, "Invalid local uri '%s'.", transport->url);
+
+ path++;
+#endif
+
+ } else
path = transport->url;
error = git_repository_open(&repo, path);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to open remote");
+ t->repo = repo;
+
error = store_refs(t);
if (error < GIT_SUCCESS)
return git__rethrow(error, "Failed to retrieve references");
- t->repo = repo;
t->parent.connected = 1;
return GIT_SUCCESS;