summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-12-26 14:03:16 -0800
committerJunio C Hamano <gitster@pobox.com>2009-12-26 14:03:16 -0800
commite74f43f9b702ccb88ee83e28de13ccfaebc4abf2 (patch)
treeae30da1b3a75cb017064b497cf5a59d5c30e9b6b /transport.c
parent902f235378cb2b2f6dd5dd664b9630c95321f0ae (diff)
parentac10a85785baee56bb4a04ad5f847d15ffba0893 (diff)
downloadgit-e74f43f9b702ccb88ee83e28de13ccfaebc4abf2.tar.gz
Merge branch 'sr/vcs-helper'
* sr/vcs-helper: tests: handle NO_PYTHON setting builtin-push: don't access freed transport->url Add Python support library for remote helpers Basic build infrastructure for Python scripts Allow helpers to report in "list" command that the ref is unchanged Fix various memory leaks in transport-helper.c Allow helper to map private ref names into normal names Add support for "import" helper command Allow specifying the remote helper in the url Add a config option for remotes to specify a foreign vcs Allow fetch to modify refs Use a function to determine whether a remote is valid Allow programs to not depend on remotes having urls Fix memory leak in helper method for disconnect Conflicts: Documentation/git-remote-helpers.txt Makefile builtin-ls-remote.c builtin-push.c transport-helper.c
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/transport.c b/transport.c
index 7362ec09b2..3eea836a33 100644
--- a/transport.c
+++ b/transport.c
@@ -204,7 +204,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
}
static int fetch_objs_via_rsync(struct transport *transport,
- int nr_objs, const struct ref **to_fetch)
+ int nr_objs, struct ref **to_fetch)
{
struct strbuf buf = STRBUF_INIT;
struct child_process rsync;
@@ -379,7 +379,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport, int for_pus
}
static int fetch_refs_from_bundle(struct transport *transport,
- int nr_heads, const struct ref **to_fetch)
+ int nr_heads, struct ref **to_fetch)
{
struct bundle_transport_data *data = transport->data;
return unbundle(&data->header, data->fd);
@@ -457,7 +457,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
}
static int fetch_refs_via_pack(struct transport *transport,
- int nr_heads, const struct ref **to_fetch)
+ int nr_heads, struct ref **to_fetch)
{
struct git_transport_data *data = transport->data;
char **heads = xmalloc(nr_heads * sizeof(*heads));
@@ -788,8 +788,26 @@ struct transport *transport_get(struct remote *remote, const char *url)
die("No remote provided to transport_get()");
ret->remote = remote;
+
+ if (!url && remote && remote->url)
+ url = remote->url[0];
ret->url = url;
+ /* maybe it is a foreign URL? */
+ if (url) {
+ const char *p = url;
+
+ while (isalnum(*p))
+ p++;
+ if (!prefixcmp(p, "::"))
+ remote->foreign_vcs = xstrndup(url, p - url);
+ }
+
+ if (remote && remote->foreign_vcs) {
+ transport_helper_init(ret, remote->foreign_vcs);
+ return ret;
+ }
+
if (!prefixcmp(url, "rsync:")) {
ret->get_refs_list = get_refs_via_rsync;
ret->fetch = fetch_objs_via_rsync;
@@ -896,16 +914,17 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
return transport->remote_refs;
}
-int transport_fetch_refs(struct transport *transport, const struct ref *refs)
+int transport_fetch_refs(struct transport *transport, struct ref *refs)
{
int rc;
int nr_heads = 0, nr_alloc = 0, nr_refs = 0;
- const struct ref **heads = NULL;
- const struct ref *rm;
+ struct ref **heads = NULL;
+ struct ref *rm;
for (rm = refs; rm; rm = rm->next) {
nr_refs++;
if (rm->peer_ref &&
+ !is_null_sha1(rm->old_sha1) &&
!hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))
continue;
ALLOC_GROW(heads, nr_heads + 1, nr_alloc);