free_refs(local_refs);
}
-static int push_url_of_remote(struct remote *remote, const char ***url_p)
-{
- if (remote->pushurl.nr) {
- *url_p = remote->pushurl.v;
- return remote->pushurl.nr;
- }
- *url_p = remote->url.v;
- return remote->url.nr;
-}
-
static NORETURN void die_push_simple(struct branch *branch,
struct remote *remote)
{
struct remote *remote)
{
int i, errs;
- const char **url;
- int url_nr;
+ struct strvec *url;
struct refspec *push_refspec = &rs;
if (push_options->nr)
setup_default_push_refspecs(&flags, remote);
}
errs = 0;
- url_nr = push_url_of_remote(remote, &url);
- if (url_nr) {
- for (i = 0; i < url_nr; i++) {
+ url = push_url_of_remote(remote);
+ if (url->nr) {
+ for (i = 0; i < url->nr; i++) {
struct transport *transport =
- transport_get(remote, url[i]);
+ transport_get(remote, url->v[i]);
if (flags & TRANSPORT_PUSH_OPTIONS)
transport->push_options = push_options;
if (push_with_options(transport, push_refspec, flags))
{
struct string_list *list = priv;
struct strbuf remote_info_buf = STRBUF_INIT;
- const char **url;
- int i, url_nr;
+ struct strvec *url;
+ int i;
if (remote->url.nr > 0) {
struct strbuf promisor_config = STRBUF_INIT;
strbuf_detach(&remote_info_buf, NULL);
} else
string_list_append(list, remote->name)->util = NULL;
- if (remote->pushurl.nr) {
- url = remote->pushurl.v;
- url_nr = remote->pushurl.nr;
- } else {
- url = remote->url.v;
- url_nr = remote->url.nr;
- }
- for (i = 0; i < url_nr; i++)
+ url = push_url_of_remote(remote);
+ for (i = 0; i < url->nr; i++)
{
- strbuf_addf(&remote_info_buf, "%s (push)", url[i]);
+ strbuf_addf(&remote_info_buf, "%s (push)", url->v[i]);
string_list_append(list, remote->name)->util =
strbuf_detach(&remote_info_buf, NULL);
}
for (; argc; argc--, argv++) {
int i;
- const char **url;
- int url_nr;
+ struct strvec *url;
get_remote_ref_states(*argv, &info.states, query_flag);
printf_ln(_("* remote %s"), *argv);
printf_ln(_(" Fetch URL: %s"), info.states.remote->url.nr > 0 ?
info.states.remote->url.v[0] : _("(no URL)"));
- if (info.states.remote->pushurl.nr) {
- url = info.states.remote->pushurl.v;
- url_nr = info.states.remote->pushurl.nr;
- } else {
- url = info.states.remote->url.v;
- url_nr = info.states.remote->url.nr;
- }
- for (i = 0; i < url_nr; i++)
+ url = push_url_of_remote(info.states.remote);
+ for (i = 0; i < url->nr; i++)
/*
* TRANSLATORS: the colon ':' should align
* with the one in " Fetch URL: %s"
* translation.
*/
- printf_ln(_(" Push URL: %s"), url[i]);
+ printf_ln(_(" Push URL: %s"), url->v[i]);
if (!i)
printf_ln(_(" Push URL: %s"), _("(no URL)"));
if (no_query)
int i, push_mode = 0, all_mode = 0;
const char *remotename = NULL;
struct remote *remote;
- const char **url;
- int url_nr;
+ struct strvec *url;
struct option options[] = {
OPT_BOOL('\0', "push", &push_mode,
N_("query push URLs rather than fetch URLs")),
exit(2);
}
- url_nr = 0;
- if (push_mode) {
- url = remote->pushurl.v;
- url_nr = remote->pushurl.nr;
- }
- /* else fetch mode */
-
- /* Use the fetch URL when no push URLs were found or requested. */
- if (!url_nr) {
- url = remote->url.v;
- url_nr = remote->url.nr;
- }
-
- if (!url_nr)
+ url = push_mode ? push_url_of_remote(remote) : &remote->url;
+ if (!url->nr)
die(_("no URLs configured for remote '%s'"), remotename);
if (all_mode) {
- for (i = 0; i < url_nr; i++)
- printf_ln("%s", url[i]);
+ for (i = 0; i < url->nr; i++)
+ printf_ln("%s", url->v[i]);
} else {
- printf_ln("%s", *url);
+ printf_ln("%s", url->v[0]);
}
return 0;
const char *oldurl = NULL;
struct remote *remote;
regex_t old_regex;
- const char **urlset;
- int urlset_nr;
+ struct strvec *urlset;
struct strbuf name_buf = STRBUF_INIT;
struct option options[] = {
OPT_BOOL('\0', "push", &push_mode,
if (push_mode) {
strbuf_addf(&name_buf, "remote.%s.pushurl", remotename);
- urlset = remote->pushurl.v;
- urlset_nr = remote->pushurl.nr;
+ urlset = &remote->pushurl;
} else {
strbuf_addf(&name_buf, "remote.%s.url", remotename);
- urlset = remote->url.v;
- urlset_nr = remote->url.nr;
+ urlset = &remote->url;
}
/* Special cases that add new entry. */
if (regcomp(&old_regex, oldurl, REG_EXTENDED))
die(_("Invalid old URL pattern: %s"), oldurl);
- for (i = 0; i < urlset_nr; i++)
- if (!regexec(&old_regex, urlset[i], 0, NULL, 0))
+ for (i = 0; i < urlset->nr; i++)
+ if (!regexec(&old_regex, urlset->v[i], 0, NULL, 0))
matches++;
else
negative_matches++;