1213
{
1214
struct string_list *list = priv;
1215
struct strbuf remote_info_buf = STRBUF_INIT;
1216
- const char **url;
1217
- int i, url_nr;
1216
+ struct strvec *url;
1217
+ int i;
1218
1219
if (remote->url.nr > 0) {
1220
struct strbuf promisor_config = STRBUF_INIT;
1230
strbuf_detach(&remote_info_buf, NULL);
1231
} else
1232
string_list_append(list, remote->name)->util = NULL;
1233
- if (remote->pushurl.nr) {
1234
- url = remote->pushurl.v;
1235
- url_nr = remote->pushurl.nr;
1236
- } else {
1237
- url = remote->url.v;
1238
- url_nr = remote->url.nr;
1239
- }
1240
- for (i = 0; i < url_nr; i++)
1233
+ url = push_url_of_remote(remote);
1234
+ for (i = 0; i < url->nr; i++)
1235
{
1242
- strbuf_addf(&remote_info_buf, "%s (push)", url[i]);
1236
+ strbuf_addf(&remote_info_buf, "%s (push)", url->v[i]);
1237
string_list_append(list, remote->name)->util =
1238
strbuf_detach(&remote_info_buf, NULL);
1239
}
1289
1290
for (; argc; argc--, argv++) {
1291
int i;
1298
- const char **url;
1299
- int url_nr;
1292
+ struct strvec *url;
1293
1294
get_remote_ref_states(*argv, &info.states, query_flag);
1295
1296
printf_ln(_("* remote %s"), *argv);
1297
printf_ln(_(" Fetch URL: %s"), info.states.remote->url.nr > 0 ?
1298
info.states.remote->url.v[0] : _("(no URL)"));
1306
- if (info.states.remote->pushurl.nr) {
1307
- url = info.states.remote->pushurl.v;
1308
- url_nr = info.states.remote->pushurl.nr;
1309
- } else {
1310
- url = info.states.remote->url.v;
1311
- url_nr = info.states.remote->url.nr;
1312
- }
1313
- for (i = 0; i < url_nr; i++)
1299
+ url = push_url_of_remote(info.states.remote);
1300
+ for (i = 0; i < url->nr; i++)
1301
/*
1302
* TRANSLATORS: the colon ':' should align
1303
* with the one in " Fetch URL: %s"
1304
* translation.
1305
*/
1319
- printf_ln(_(" Push URL: %s"), url[i]);
1306
+ printf_ln(_(" Push URL: %s"), url->v[i]);
1307
if (!i)
1308
printf_ln(_(" Push URL: %s"), _("(no URL)"));
1309
if (no_query)
1609
int i, push_mode = 0, all_mode = 0;
1610
const char *remotename = NULL;
1611
struct remote *remote;
1625
- const char **url;
1626
- int url_nr;
1612
+ struct strvec *url;
1613
struct option options[] = {
1614
OPT_BOOL('\0', "push", &push_mode,
1615
N_("query push URLs rather than fetch URLs")),
1631
exit(2);
1632
}
1633
1648
- url_nr = 0;
1649
- if (push_mode) {
1650
- url = remote->pushurl.v;
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.v;
1658
- url_nr = remote->url.nr;
1659
- }
1660
-
1661
- if (!url_nr)
1634
+ url = push_mode ? push_url_of_remote(remote) : &remote->url;
1635
+ if (!url->nr)
1636
die(_("no URLs configured for remote '%s'"), remotename);
1637
1638
if (all_mode) {
1665
- for (i = 0; i < url_nr; i++)
1666
- printf_ln("%s", url[i]);
1639
+ for (i = 0; i < url->nr; i++)
1640
+ printf_ln("%s", url->v[i]);
1641
} else {
1668
- printf_ln("%s", *url);
1642
+ printf_ln("%s", url->v[0]);
1643
}
1644
1645
return 0;
1654
const char *oldurl = NULL;
1655
struct remote *remote;
1656
regex_t old_regex;
1683
- const char **urlset;
1684
- int urlset_nr;
1657
+ struct strvec *urlset;
1658
struct strbuf name_buf = STRBUF_INIT;
1659
struct option options[] = {
1660
OPT_BOOL('\0', "push", &push_mode,
1691
1692
if (push_mode) {
1693
strbuf_addf(&name_buf, "remote.%s.pushurl", remotename);
1721
- urlset = remote->pushurl.v;
1722
- urlset_nr = remote->pushurl.nr;
1694
+ urlset = &remote->pushurl;
1695
} else {
1696
strbuf_addf(&name_buf, "remote.%s.url", remotename);
1725
- urlset = remote->url.v;
1726
- urlset_nr = remote->url.nr;
1697
+ urlset = &remote->url;
1698
}
1699
1700
/* Special cases that add new entry. */
1711
if (regcomp(&old_regex, oldurl, REG_EXTENDED))
1712
die(_("Invalid old URL pattern: %s"), oldurl);
1713
1743
- for (i = 0; i < urlset_nr; i++)
1744
- if (!regexec(&old_regex, urlset[i], 0, NULL, 0))
1714
+ for (i = 0; i < urlset->nr; i++)
1715
+ if (!regexec(&old_regex, urlset->v[i], 0, NULL, 0))
1716
matches++;
1717
else
1718
negative_matches++;