remote: drop checks for zero-url case
Now that the previous commit removed the possibility that a "struct remote" will ever have zero url fields, we can drop a number of redundant checks and untriggerable code paths. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
ffce821880
commit
aecd794fca
|
@ -31,8 +31,6 @@ static int run_remote_archiver(int argc, const char **argv,
|
||||||
struct packet_reader reader;
|
struct packet_reader reader;
|
||||||
|
|
||||||
_remote = remote_get(remote);
|
_remote = remote_get(remote);
|
||||||
if (!_remote->url.nr)
|
|
||||||
die(_("git archive: Remote with no URL"));
|
|
||||||
transport = transport_get(_remote, _remote->url.v[0]);
|
transport = transport_get(_remote, _remote->url.v[0]);
|
||||||
transport_connect(transport, "git-upload-archive", exec, fd);
|
transport_connect(transport, "git-upload-archive", exec, fd);
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
|
||||||
die("bad repository '%s'", dest);
|
die("bad repository '%s'", dest);
|
||||||
die("No remote configured to list refs from.");
|
die("No remote configured to list refs from.");
|
||||||
}
|
}
|
||||||
if (!remote->url.nr)
|
|
||||||
die("remote %s has no configured URL", dest);
|
|
||||||
|
|
||||||
if (get_url) {
|
if (get_url) {
|
||||||
printf("%s\n", remote->url.v[0]);
|
printf("%s\n", remote->url.v[0]);
|
||||||
|
|
|
@ -438,18 +438,9 @@ static int do_push(int flags,
|
||||||
}
|
}
|
||||||
errs = 0;
|
errs = 0;
|
||||||
url = push_url_of_remote(remote);
|
url = push_url_of_remote(remote);
|
||||||
if (url->nr) {
|
for (i = 0; i < url->nr; i++) {
|
||||||
for (i = 0; i < url->nr; i++) {
|
|
||||||
struct transport *transport =
|
|
||||||
transport_get(remote, url->v[i]);
|
|
||||||
if (flags & TRANSPORT_PUSH_OPTIONS)
|
|
||||||
transport->push_options = push_options;
|
|
||||||
if (push_with_options(transport, push_refspec, flags))
|
|
||||||
errs++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
struct transport *transport =
|
struct transport *transport =
|
||||||
transport_get(remote, NULL);
|
transport_get(remote, url->v[i]);
|
||||||
if (flags & TRANSPORT_PUSH_OPTIONS)
|
if (flags & TRANSPORT_PUSH_OPTIONS)
|
||||||
transport->push_options = push_options;
|
transport->push_options = push_options;
|
||||||
if (push_with_options(transport, push_refspec, flags))
|
if (push_with_options(transport, push_refspec, flags))
|
||||||
|
|
|
@ -1002,8 +1002,7 @@ static int get_remote_ref_states(const char *name,
|
||||||
struct transport *transport;
|
struct transport *transport;
|
||||||
const struct ref *remote_refs;
|
const struct ref *remote_refs;
|
||||||
|
|
||||||
transport = transport_get(states->remote, states->remote->url.nr > 0 ?
|
transport = transport_get(states->remote, states->remote->url.v[0]);
|
||||||
states->remote->url.v[0] : NULL);
|
|
||||||
remote_refs = transport_get_remote_refs(transport, NULL);
|
remote_refs = transport_get_remote_refs(transport, NULL);
|
||||||
|
|
||||||
states->queried = 1;
|
states->queried = 1;
|
||||||
|
@ -1294,8 +1293,7 @@ static int show(int argc, const char **argv, const char *prefix)
|
||||||
get_remote_ref_states(*argv, &info.states, query_flag);
|
get_remote_ref_states(*argv, &info.states, query_flag);
|
||||||
|
|
||||||
printf_ln(_("* remote %s"), *argv);
|
printf_ln(_("* remote %s"), *argv);
|
||||||
printf_ln(_(" Fetch URL: %s"), info.states.remote->url.nr > 0 ?
|
printf_ln(_(" Fetch URL: %s"), info.states.remote->url.v[0]);
|
||||||
info.states.remote->url.v[0] : _("(no URL)"));
|
|
||||||
url = push_url_of_remote(info.states.remote);
|
url = push_url_of_remote(info.states.remote);
|
||||||
for (i = 0; i < url->nr; i++)
|
for (i = 0; i < url->nr; i++)
|
||||||
/*
|
/*
|
||||||
|
@ -1440,10 +1438,7 @@ static int prune_remote(const char *remote, int dry_run)
|
||||||
}
|
}
|
||||||
|
|
||||||
printf_ln(_("Pruning %s"), remote);
|
printf_ln(_("Pruning %s"), remote);
|
||||||
printf_ln(_("URL: %s"),
|
printf_ln(_("URL: %s"), states.remote->url.v[0]);
|
||||||
states.remote->url.nr
|
|
||||||
? states.remote->url.v[0]
|
|
||||||
: _("(no URL)"));
|
|
||||||
|
|
||||||
for_each_string_list_item(item, &states.stale)
|
for_each_string_list_item(item, &states.stale)
|
||||||
string_list_append(&refs_to_prune, item->util);
|
string_list_append(&refs_to_prune, item->util);
|
||||||
|
@ -1632,8 +1627,6 @@ static int get_url(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
url = push_mode ? push_url_of_remote(remote) : &remote->url;
|
url = push_mode ? push_url_of_remote(remote) : &remote->url;
|
||||||
if (!url->nr)
|
|
||||||
die(_("no URLs configured for remote '%s'"), remotename);
|
|
||||||
|
|
||||||
if (all_mode) {
|
if (all_mode) {
|
||||||
for (i = 0; i < url->nr; i++)
|
for (i = 0; i < url->nr; i++)
|
||||||
|
|
|
@ -88,8 +88,6 @@ static int cmd_ls_remote(int argc, const char **argv)
|
||||||
die(_("bad repository '%s'"), dest);
|
die(_("bad repository '%s'"), dest);
|
||||||
die(_("no remote configured to get bundle URIs from"));
|
die(_("no remote configured to get bundle URIs from"));
|
||||||
}
|
}
|
||||||
if (!remote->url.nr)
|
|
||||||
die(_("remote '%s' has no configured URL"), dest);
|
|
||||||
|
|
||||||
transport = transport_get(remote, NULL);
|
transport = transport_get(remote, NULL);
|
||||||
if (transport_get_remote_bundle_uri(transport) < 0) {
|
if (transport_get_remote_bundle_uri(transport) < 0) {
|
||||||
|
|
17
transport.c
17
transport.c
|
@ -1112,6 +1112,7 @@ static struct transport_vtable builtin_smart_vtable = {
|
||||||
struct transport *transport_get(struct remote *remote, const char *url)
|
struct transport *transport_get(struct remote *remote, const char *url)
|
||||||
{
|
{
|
||||||
const char *helper;
|
const char *helper;
|
||||||
|
const char *p;
|
||||||
struct transport *ret = xcalloc(1, sizeof(*ret));
|
struct transport *ret = xcalloc(1, sizeof(*ret));
|
||||||
|
|
||||||
ret->progress = isatty(2);
|
ret->progress = isatty(2);
|
||||||
|
@ -1127,19 +1128,15 @@ struct transport *transport_get(struct remote *remote, const char *url)
|
||||||
ret->remote = remote;
|
ret->remote = remote;
|
||||||
helper = remote->foreign_vcs;
|
helper = remote->foreign_vcs;
|
||||||
|
|
||||||
if (!url && remote->url.nr)
|
if (!url)
|
||||||
url = remote->url.v[0];
|
url = remote->url.v[0];
|
||||||
ret->url = url;
|
ret->url = url;
|
||||||
|
|
||||||
/* maybe it is a foreign URL? */
|
p = url;
|
||||||
if (url) {
|
while (is_urlschemechar(p == url, *p))
|
||||||
const char *p = url;
|
p++;
|
||||||
|
if (starts_with(p, "::"))
|
||||||
while (is_urlschemechar(p == url, *p))
|
helper = xstrndup(url, p - url);
|
||||||
p++;
|
|
||||||
if (starts_with(p, "::"))
|
|
||||||
helper = xstrndup(url, p - url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (helper) {
|
if (helper) {
|
||||||
transport_helper_init(ret, helper);
|
transport_helper_init(ret, helper);
|
||||||
|
|
Loading…
Reference in New Issue