@@ -854,8 +854,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
854854 struct xml_ctx ctx ;
855855 char * escaped ;
856856
857- url = xmalloc (strlen (repo -> url ) + strlen (path ) + 1 );
858- sprintf (url , "%s%s" , repo -> url , path );
857+ url = xstrfmt ("%s%s" , repo -> url , path );
859858
860859 /* Make sure leading directories exist for the remote ref */
861860 ep = strchr (url + strlen (repo -> url ) + 1 , '/' );
@@ -1115,7 +1114,7 @@ static void remote_ls(const char *path, int flags,
11151114 void (* userFunc )(struct remote_ls_ctx * ls ),
11161115 void * userData )
11171116{
1118- char * url = xmalloc ( strlen ( repo -> url ) + strlen ( path ) + 1 );
1117+ char * url = xstrfmt ( "%s%s" , repo -> url , path );
11191118 struct active_request_slot * slot ;
11201119 struct slot_results results ;
11211120 struct strbuf in_buffer = STRBUF_INIT ;
@@ -1131,8 +1130,6 @@ static void remote_ls(const char *path, int flags,
11311130 ls .userData = userData ;
11321131 ls .userFunc = userFunc ;
11331132
1134- sprintf (url , "%s%s" , repo -> url , path );
1135-
11361133 strbuf_addf (& out_buffer .buf , PROPFIND_ALL_REQUEST );
11371134
11381135 dav_headers = curl_slist_append (dav_headers , "Depth: 1" );
@@ -1534,10 +1531,9 @@ static void update_remote_info_refs(struct remote_lock *lock)
15341531
15351532static int remote_exists (const char * path )
15361533{
1537- char * url = xmalloc ( strlen ( repo -> url ) + strlen ( path ) + 1 );
1534+ char * url = xstrfmt ( "%s%s" , repo -> url , path );
15381535 int ret ;
15391536
1540- sprintf (url , "%s%s" , repo -> url , path );
15411537
15421538 switch (http_get_strbuf (url , NULL , NULL )) {
15431539 case HTTP_OK :
@@ -1557,12 +1553,9 @@ static int remote_exists(const char *path)
15571553
15581554static void fetch_symref (const char * path , char * * symref , unsigned char * sha1 )
15591555{
1560- char * url ;
1556+ char * url = xstrfmt ( "%s%s" , repo -> url , path ) ;
15611557 struct strbuf buffer = STRBUF_INIT ;
15621558
1563- url = xmalloc (strlen (repo -> url ) + strlen (path ) + 1 );
1564- sprintf (url , "%s%s" , repo -> url , path );
1565-
15661559 if (http_get_strbuf (url , & buffer , NULL ) != HTTP_OK )
15671560 die ("Couldn't get %s for remote symref\n%s" , url ,
15681561 curl_errorstr );
@@ -1671,8 +1664,7 @@ static int delete_remote_branch(const char *pattern, int force)
16711664 fprintf (stderr , "Removing remote branch '%s'\n" , remote_ref -> name );
16721665 if (dry_run )
16731666 return 0 ;
1674- url = xmalloc (strlen (repo -> url ) + strlen (remote_ref -> name ) + 1 );
1675- sprintf (url , "%s%s" , repo -> url , remote_ref -> name );
1667+ url = xstrfmt ("%s%s" , repo -> url , remote_ref -> name );
16761668 slot = get_active_slot ();
16771669 slot -> results = & results ;
16781670 curl_setup_http_get (slot -> curl , url , DAV_DELETE );
0 commit comments