@@ -619,8 +619,8 @@ static int migrate_file(struct remote *remote)
619
619
int i ;
620
620
621
621
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 );
624
624
strbuf_reset (& buf );
625
625
strbuf_addf (& buf , "remote.%s.push" , remote -> name );
626
626
for (i = 0 ; i < remote -> push .raw_nr ; i ++ )
@@ -1002,8 +1002,7 @@ static int get_remote_ref_states(const char *name,
1002
1002
struct transport * transport ;
1003
1003
const struct ref * remote_refs ;
1004
1004
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 ]);
1007
1006
remote_refs = transport_get_remote_refs (transport , NULL );
1008
1007
1009
1008
states -> queried = 1 ;
@@ -1213,15 +1212,15 @@ static int get_one_entry(struct remote *remote, void *priv)
1213
1212
{
1214
1213
struct string_list * list = priv ;
1215
1214
struct strbuf remote_info_buf = STRBUF_INIT ;
1216
- const char * * url ;
1217
- int i , url_nr ;
1215
+ struct strvec * url ;
1216
+ int i ;
1218
1217
1219
- if (remote -> url_nr > 0 ) {
1218
+ if (remote -> url . nr > 0 ) {
1220
1219
struct strbuf promisor_config = STRBUF_INIT ;
1221
1220
const char * partial_clone_filter = NULL ;
1222
1221
1223
1222
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 ]);
1225
1224
if (!git_config_get_string_tmp (promisor_config .buf , & partial_clone_filter ))
1226
1225
strbuf_addf (& remote_info_buf , " [%s]" , partial_clone_filter );
1227
1226
@@ -1230,16 +1229,10 @@ static int get_one_entry(struct remote *remote, void *priv)
1230
1229
strbuf_detach (& remote_info_buf , NULL );
1231
1230
} else
1232
1231
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 ++ )
1241
1234
{
1242
- strbuf_addf (& remote_info_buf , "%s (push)" , url [i ]);
1235
+ strbuf_addf (& remote_info_buf , "%s (push)" , url -> v [i ]);
1243
1236
string_list_append (list , remote -> name )-> util =
1244
1237
strbuf_detach (& remote_info_buf , NULL );
1245
1238
}
@@ -1295,28 +1288,20 @@ static int show(int argc, const char **argv, const char *prefix)
1295
1288
1296
1289
for (; argc ; argc -- , argv ++ ) {
1297
1290
int i ;
1298
- const char * * url ;
1299
- int url_nr ;
1291
+ struct strvec * url ;
1300
1292
1301
1293
get_remote_ref_states (* argv , & info .states , query_flag );
1302
1294
1303
1295
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 ++ )
1314
1299
/*
1315
1300
* TRANSLATORS: the colon ':' should align
1316
1301
* with the one in " Fetch URL: %s"
1317
1302
* translation.
1318
1303
*/
1319
- printf_ln (_ (" Push URL: %s" ), url [i ]);
1304
+ printf_ln (_ (" Push URL: %s" ), url -> v [i ]);
1320
1305
if (!i )
1321
1306
printf_ln (_ (" Push URL: %s" ), _ ("(no URL)" ));
1322
1307
if (no_query )
@@ -1453,10 +1438,7 @@ static int prune_remote(const char *remote, int dry_run)
1453
1438
}
1454
1439
1455
1440
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 ]);
1460
1442
1461
1443
for_each_string_list_item (item , & states .stale )
1462
1444
string_list_append (& refs_to_prune , item -> util );
@@ -1622,8 +1604,7 @@ static int get_url(int argc, const char **argv, const char *prefix)
1622
1604
int i , push_mode = 0 , all_mode = 0 ;
1623
1605
const char * remotename = NULL ;
1624
1606
struct remote * remote ;
1625
- const char * * url ;
1626
- int url_nr ;
1607
+ struct strvec * url ;
1627
1608
struct option options [] = {
1628
1609
OPT_BOOL ('\0' , "push" , & push_mode ,
1629
1610
N_ ("query push URLs rather than fetch URLs" )),
@@ -1645,27 +1626,13 @@ static int get_url(int argc, const char **argv, const char *prefix)
1645
1626
exit (2 );
1646
1627
}
1647
1628
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 ;
1663
1630
1664
1631
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 ]);
1667
1634
} else {
1668
- printf_ln ("%s" , * url );
1635
+ printf_ln ("%s" , url -> v [ 0 ] );
1669
1636
}
1670
1637
1671
1638
return 0 ;
@@ -1680,8 +1647,7 @@ static int set_url(int argc, const char **argv, const char *prefix)
1680
1647
const char * oldurl = NULL ;
1681
1648
struct remote * remote ;
1682
1649
regex_t old_regex ;
1683
- const char * * urlset ;
1684
- int urlset_nr ;
1650
+ struct strvec * urlset ;
1685
1651
struct strbuf name_buf = STRBUF_INIT ;
1686
1652
struct option options [] = {
1687
1653
OPT_BOOL ('\0' , "push" , & push_mode ,
@@ -1718,12 +1684,10 @@ static int set_url(int argc, const char **argv, const char *prefix)
1718
1684
1719
1685
if (push_mode ) {
1720
1686
strbuf_addf (& name_buf , "remote.%s.pushurl" , remotename );
1721
- urlset = remote -> pushurl ;
1722
- urlset_nr = remote -> pushurl_nr ;
1687
+ urlset = & remote -> pushurl ;
1723
1688
} else {
1724
1689
strbuf_addf (& name_buf , "remote.%s.url" , remotename );
1725
- urlset = remote -> url ;
1726
- urlset_nr = remote -> url_nr ;
1690
+ urlset = & remote -> url ;
1727
1691
}
1728
1692
1729
1693
/* Special cases that add new entry. */
@@ -1740,8 +1704,8 @@ static int set_url(int argc, const char **argv, const char *prefix)
1740
1704
if (regcomp (& old_regex , oldurl , REG_EXTENDED ))
1741
1705
die (_ ("Invalid old URL pattern: %s" ), oldurl );
1742
1706
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 ))
1745
1709
matches ++ ;
1746
1710
else
1747
1711
negative_matches ++ ;
0 commit comments