@@ -138,6 +138,11 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
138138 }
139139}
140140
141+ static const char * rsync_url (const char * url )
142+ {
143+ return prefixcmp (url , "rsync://" ) ? skip_prefix (url , "rsync:" ) : url ;
144+ }
145+
141146static struct ref * get_refs_via_rsync (struct transport * transport )
142147{
143148 struct strbuf buf = STRBUF_INIT , temp_dir = STRBUF_INIT ;
@@ -153,7 +158,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
153158 die ("Could not make temporary directory" );
154159 temp_dir_len = temp_dir .len ;
155160
156- strbuf_addstr (& buf , transport -> url );
161+ strbuf_addstr (& buf , rsync_url ( transport -> url ) );
157162 strbuf_addstr (& buf , "/refs" );
158163
159164 memset (& rsync , 0 , sizeof (rsync ));
@@ -169,7 +174,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
169174 die ("Could not run rsync to get refs" );
170175
171176 strbuf_reset (& buf );
172- strbuf_addstr (& buf , transport -> url );
177+ strbuf_addstr (& buf , rsync_url ( transport -> url ) );
173178 strbuf_addstr (& buf , "/packed-refs" );
174179
175180 args [2 ] = buf .buf ;
@@ -206,7 +211,7 @@ static int fetch_objs_via_rsync(struct transport *transport,
206211 const char * args [8 ];
207212 int result ;
208213
209- strbuf_addstr (& buf , transport -> url );
214+ strbuf_addstr (& buf , rsync_url ( transport -> url ) );
210215 strbuf_addstr (& buf , "/objects/" );
211216
212217 memset (& rsync , 0 , sizeof (rsync ));
@@ -285,7 +290,7 @@ static int rsync_transport_push(struct transport *transport,
285290
286291 /* first push the objects */
287292
288- strbuf_addstr (& buf , transport -> url );
293+ strbuf_addstr (& buf , rsync_url ( transport -> url ) );
289294 strbuf_addch (& buf , '/' );
290295
291296 memset (& rsync , 0 , sizeof (rsync ));
@@ -306,7 +311,8 @@ static int rsync_transport_push(struct transport *transport,
306311 args [i ++ ] = NULL ;
307312
308313 if (run_command (& rsync ))
309- return error ("Could not push objects to %s" , transport -> url );
314+ return error ("Could not push objects to %s" ,
315+ rsync_url (transport -> url ));
310316
311317 /* copy the refs to the temporary directory; they could be packed. */
312318
@@ -327,10 +333,11 @@ static int rsync_transport_push(struct transport *transport,
327333 if (!(flags & TRANSPORT_PUSH_FORCE ))
328334 args [i ++ ] = "--ignore-existing" ;
329335 args [i ++ ] = temp_dir .buf ;
330- args [i ++ ] = transport -> url ;
336+ args [i ++ ] = rsync_url ( transport -> url ) ;
331337 args [i ++ ] = NULL ;
332338 if (run_command (& rsync ))
333- result = error ("Could not push to %s" , transport -> url );
339+ result = error ("Could not push to %s" ,
340+ rsync_url (transport -> url ));
334341
335342 if (remove_dir_recursively (& temp_dir , 0 ))
336343 warning ("Could not remove temporary directory %s." ,
@@ -723,7 +730,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
723730 ret -> remote = remote ;
724731 ret -> url = url ;
725732
726- if (!prefixcmp (url , "rsync:// " )) {
733+ if (!prefixcmp (url , "rsync:" )) {
727734 ret -> get_refs_list = get_refs_via_rsync ;
728735 ret -> fetch = fetch_objs_via_rsync ;
729736 ret -> push = rsync_transport_push ;
0 commit comments