aboutsummaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2009-03-09 19:44:55 +0100
committerJunio C Hamano <gitster@pobox.com>2009-03-10 23:17:56 -0700
commit7efaeba2a8006bb52712eb90c6fbc736b9632cab (patch)
treeb70efc303aa4a4f695628cc036e12759eac7b88c /transport.c
parent9a6682bab5e800465f0a4e44cdf18fe396ff4f6d (diff)
downloadgit-7efaeba2a8006bb52712eb90c6fbc736b9632cab.tar.gz
git-7efaeba2a8006bb52712eb90c6fbc736b9632cab.tar.xz
rsync transport: allow local paths, and fix tests
Earlier, the rsync tests were disabled by default, as they needed a running rsyncd daemon. This was only due to the limitation that our rsync transport only allowed full URLs of the form rsync://<host>/<path> Relaxing the URLs to allow rsync:<path> permitted the change in the tests to run whenever rsync is available, without requiring a fully configured and running rsyncd. While at it, the tests were fixed so that they run in directories with a space in their name. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/transport.c b/transport.c
index 9ad4a16c3..9ae92cd39 100644
--- a/transport.c
+++ b/transport.c
@@ -138,6 +138,11 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
}
}
+static const char *rsync_url(const char *url)
+{
+ return prefixcmp(url, "rsync://") ? skip_prefix(url, "rsync:") : url;
+}
+
static struct ref *get_refs_via_rsync(struct transport *transport)
{
struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
@@ -153,7 +158,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
die ("Could not make temporary directory");
temp_dir_len = temp_dir.len;
- strbuf_addstr(&buf, transport->url);
+ strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addstr(&buf, "/refs");
memset(&rsync, 0, sizeof(rsync));
@@ -169,7 +174,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
die ("Could not run rsync to get refs");
strbuf_reset(&buf);
- strbuf_addstr(&buf, transport->url);
+ strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addstr(&buf, "/packed-refs");
args[2] = buf.buf;
@@ -206,7 +211,7 @@ static int fetch_objs_via_rsync(struct transport *transport,
const char *args[8];
int result;
- strbuf_addstr(&buf, transport->url);
+ strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addstr(&buf, "/objects/");
memset(&rsync, 0, sizeof(rsync));
@@ -285,7 +290,7 @@ static int rsync_transport_push(struct transport *transport,
/* first push the objects */
- strbuf_addstr(&buf, transport->url);
+ strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addch(&buf, '/');
memset(&rsync, 0, sizeof(rsync));
@@ -306,7 +311,8 @@ static int rsync_transport_push(struct transport *transport,
args[i++] = NULL;
if (run_command(&rsync))
- return error("Could not push objects to %s", transport->url);
+ return error("Could not push objects to %s",
+ rsync_url(transport->url));
/* copy the refs to the temporary directory; they could be packed. */
@@ -327,10 +333,11 @@ static int rsync_transport_push(struct transport *transport,
if (!(flags & TRANSPORT_PUSH_FORCE))
args[i++] = "--ignore-existing";
args[i++] = temp_dir.buf;
- args[i++] = transport->url;
+ args[i++] = rsync_url(transport->url);
args[i++] = NULL;
if (run_command(&rsync))
- result = error("Could not push to %s", transport->url);
+ result = error("Could not push to %s",
+ rsync_url(transport->url));
if (remove_dir_recursively(&temp_dir, 0))
warning ("Could not remove temporary directory %s.",
@@ -723,7 +730,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
ret->remote = remote;
ret->url = url;
- if (!prefixcmp(url, "rsync://")) {
+ if (!prefixcmp(url, "rsync:")) {
ret->get_refs_list = get_refs_via_rsync;
ret->fetch = fetch_objs_via_rsync;
ret->push = rsync_transport_push;