@@ -619,8 +619,8 @@ static int migrate_file(struct remote *remote)
619619 int i ;
620620
621621 strbuf_addf (& buf , "remote.%s.url" , remote -> name );
622- for (i = 0 ; i < remote -> url_nr ; i ++ )
623- git_config_set_multivar (buf .buf , remote -> url [i ], "^$" , 0 );
622+ for (i = 0 ; i < remote -> url . nr ; i ++ )
623+ git_config_set_multivar (buf .buf , remote -> url . v [i ], "^$" , 0 );
624624 strbuf_reset (& buf );
625625 strbuf_addf (& buf , "remote.%s.push" , remote -> name );
626626 for (i = 0 ; i < remote -> push .raw_nr ; i ++ )
@@ -1002,8 +1002,7 @@ static int get_remote_ref_states(const char *name,
10021002 struct transport * transport ;
10031003 const struct ref * remote_refs ;
10041004
1005- transport = transport_get (states -> remote , states -> remote -> url_nr > 0 ?
1006- states -> remote -> url [0 ] : NULL );
1005+ transport = transport_get (states -> remote , states -> remote -> url .v [0 ]);
10071006 remote_refs = transport_get_remote_refs (transport , NULL );
10081007
10091008 states -> queried = 1 ;
@@ -1213,15 +1212,15 @@ static int get_one_entry(struct remote *remote, void *priv)
12131212{
12141213 struct string_list * list = priv ;
12151214 struct strbuf remote_info_buf = STRBUF_INIT ;
1216- const char * * url ;
1217- int i , url_nr ;
1215+ struct strvec * url ;
1216+ int i ;
12181217
1219- if (remote -> url_nr > 0 ) {
1218+ if (remote -> url . nr > 0 ) {
12201219 struct strbuf promisor_config = STRBUF_INIT ;
12211220 const char * partial_clone_filter = NULL ;
12221221
12231222 strbuf_addf (& promisor_config , "remote.%s.partialclonefilter" , remote -> name );
1224- strbuf_addf (& remote_info_buf , "%s (fetch)" , remote -> url [0 ]);
1223+ strbuf_addf (& remote_info_buf , "%s (fetch)" , remote -> url . v [0 ]);
12251224 if (!git_config_get_string_tmp (promisor_config .buf , & partial_clone_filter ))
12261225 strbuf_addf (& remote_info_buf , " [%s]" , partial_clone_filter );
12271226
@@ -1230,16 +1229,10 @@ static int get_one_entry(struct remote *remote, void *priv)
12301229 strbuf_detach (& remote_info_buf , NULL );
12311230 } else
12321231 string_list_append (list , remote -> name )-> util = NULL ;
1233- if (remote -> pushurl_nr ) {
1234- url = remote -> pushurl ;
1235- url_nr = remote -> pushurl_nr ;
1236- } else {
1237- url = remote -> url ;
1238- url_nr = remote -> url_nr ;
1239- }
1240- for (i = 0 ; i < url_nr ; i ++ )
1232+ url = push_url_of_remote (remote );
1233+ for (i = 0 ; i < url -> nr ; i ++ )
12411234 {
1242- strbuf_addf (& remote_info_buf , "%s (push)" , url [i ]);
1235+ strbuf_addf (& remote_info_buf , "%s (push)" , url -> v [i ]);
12431236 string_list_append (list , remote -> name )-> util =
12441237 strbuf_detach (& remote_info_buf , NULL );
12451238 }
@@ -1295,28 +1288,20 @@ static int show(int argc, const char **argv, const char *prefix)
12951288
12961289 for (; argc ; argc -- , argv ++ ) {
12971290 int i ;
1298- const char * * url ;
1299- int url_nr ;
1291+ struct strvec * url ;
13001292
13011293 get_remote_ref_states (* argv , & info .states , query_flag );
13021294
13031295 printf_ln (_ ("* remote %s" ), * argv );
1304- printf_ln (_ (" Fetch URL: %s" ), info .states .remote -> url_nr > 0 ?
1305- info .states .remote -> url [0 ] : _ ("(no URL)" ));
1306- if (info .states .remote -> pushurl_nr ) {
1307- url = info .states .remote -> pushurl ;
1308- url_nr = info .states .remote -> pushurl_nr ;
1309- } else {
1310- url = info .states .remote -> url ;
1311- url_nr = info .states .remote -> url_nr ;
1312- }
1313- for (i = 0 ; i < url_nr ; i ++ )
1296+ printf_ln (_ (" Fetch URL: %s" ), info .states .remote -> url .v [0 ]);
1297+ url = push_url_of_remote (info .states .remote );
1298+ for (i = 0 ; i < url -> nr ; i ++ )
13141299 /*
13151300 * TRANSLATORS: the colon ':' should align
13161301 * with the one in " Fetch URL: %s"
13171302 * translation.
13181303 */
1319- printf_ln (_ (" Push URL: %s" ), url [i ]);
1304+ printf_ln (_ (" Push URL: %s" ), url -> v [i ]);
13201305 if (!i )
13211306 printf_ln (_ (" Push URL: %s" ), _ ("(no URL)" ));
13221307 if (no_query )
@@ -1453,10 +1438,7 @@ static int prune_remote(const char *remote, int dry_run)
14531438 }
14541439
14551440 printf_ln (_ ("Pruning %s" ), remote );
1456- printf_ln (_ ("URL: %s" ),
1457- states .remote -> url_nr
1458- ? states .remote -> url [0 ]
1459- : _ ("(no URL)" ));
1441+ printf_ln (_ ("URL: %s" ), states .remote -> url .v [0 ]);
14601442
14611443 for_each_string_list_item (item , & states .stale )
14621444 string_list_append (& refs_to_prune , item -> util );
@@ -1622,8 +1604,7 @@ static int get_url(int argc, const char **argv, const char *prefix)
16221604 int i , push_mode = 0 , all_mode = 0 ;
16231605 const char * remotename = NULL ;
16241606 struct remote * remote ;
1625- const char * * url ;
1626- int url_nr ;
1607+ struct strvec * url ;
16271608 struct option options [] = {
16281609 OPT_BOOL ('\0' , "push" , & push_mode ,
16291610 N_ ("query push URLs rather than fetch URLs" )),
@@ -1645,27 +1626,13 @@ static int get_url(int argc, const char **argv, const char *prefix)
16451626 exit (2 );
16461627 }
16471628
1648- url_nr = 0 ;
1649- if (push_mode ) {
1650- url = remote -> pushurl ;
1651- url_nr = remote -> pushurl_nr ;
1652- }
1653- /* else fetch mode */
1654-
1655- /* Use the fetch URL when no push URLs were found or requested. */
1656- if (!url_nr ) {
1657- url = remote -> url ;
1658- url_nr = remote -> url_nr ;
1659- }
1660-
1661- if (!url_nr )
1662- die (_ ("no URLs configured for remote '%s'" ), remotename );
1629+ url = push_mode ? push_url_of_remote (remote ) : & remote -> url ;
16631630
16641631 if (all_mode ) {
1665- for (i = 0 ; i < url_nr ; i ++ )
1666- printf_ln ("%s" , url [i ]);
1632+ for (i = 0 ; i < url -> nr ; i ++ )
1633+ printf_ln ("%s" , url -> v [i ]);
16671634 } else {
1668- printf_ln ("%s" , * url );
1635+ printf_ln ("%s" , url -> v [ 0 ] );
16691636 }
16701637
16711638 return 0 ;
@@ -1680,8 +1647,7 @@ static int set_url(int argc, const char **argv, const char *prefix)
16801647 const char * oldurl = NULL ;
16811648 struct remote * remote ;
16821649 regex_t old_regex ;
1683- const char * * urlset ;
1684- int urlset_nr ;
1650+ struct strvec * urlset ;
16851651 struct strbuf name_buf = STRBUF_INIT ;
16861652 struct option options [] = {
16871653 OPT_BOOL ('\0' , "push" , & push_mode ,
@@ -1718,12 +1684,10 @@ static int set_url(int argc, const char **argv, const char *prefix)
17181684
17191685 if (push_mode ) {
17201686 strbuf_addf (& name_buf , "remote.%s.pushurl" , remotename );
1721- urlset = remote -> pushurl ;
1722- urlset_nr = remote -> pushurl_nr ;
1687+ urlset = & remote -> pushurl ;
17231688 } else {
17241689 strbuf_addf (& name_buf , "remote.%s.url" , remotename );
1725- urlset = remote -> url ;
1726- urlset_nr = remote -> url_nr ;
1690+ urlset = & remote -> url ;
17271691 }
17281692
17291693 /* Special cases that add new entry. */
@@ -1740,8 +1704,8 @@ static int set_url(int argc, const char **argv, const char *prefix)
17401704 if (regcomp (& old_regex , oldurl , REG_EXTENDED ))
17411705 die (_ ("Invalid old URL pattern: %s" ), oldurl );
17421706
1743- for (i = 0 ; i < urlset_nr ; i ++ )
1744- if (!regexec (& old_regex , urlset [i ], 0 , NULL , 0 ))
1707+ for (i = 0 ; i < urlset -> nr ; i ++ )
1708+ if (!regexec (& old_regex , urlset -> v [i ], 0 , NULL , 0 ))
17451709 matches ++ ;
17461710 else
17471711 negative_matches ++ ;
0 commit comments