Skip to content

Commit aecd794

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ffce821 commit aecd794

File tree

6 files changed

+12
-37
lines changed

6 files changed

+12
-37
lines changed

builtin/archive.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ static int run_remote_archiver(int argc, const char **argv,
3131
struct packet_reader reader;
3232

3333
_remote = remote_get(remote);
34-
if (!_remote->url.nr)
35-
die(_("git archive: Remote with no URL"));
3634
transport = transport_get(_remote, _remote->url.v[0]);
3735
transport_connect(transport, "git-upload-archive", exec, fd);
3836

builtin/ls-remote.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
109109
die("bad repository '%s'", dest);
110110
die("No remote configured to list refs from.");
111111
}
112-
if (!remote->url.nr)
113-
die("remote %s has no configured URL", dest);
114112

115113
if (get_url) {
116114
printf("%s\n", remote->url.v[0]);

builtin/push.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,9 @@ static int do_push(int flags,
438438
}
439439
errs = 0;
440440
url = push_url_of_remote(remote);
441-
if (url->nr) {
442-
for (i = 0; i < url->nr; i++) {
443-
struct transport *transport =
444-
transport_get(remote, url->v[i]);
445-
if (flags & TRANSPORT_PUSH_OPTIONS)
446-
transport->push_options = push_options;
447-
if (push_with_options(transport, push_refspec, flags))
448-
errs++;
449-
}
450-
} else {
441+
for (i = 0; i < url->nr; i++) {
451442
struct transport *transport =
452-
transport_get(remote, NULL);
443+
transport_get(remote, url->v[i]);
453444
if (flags & TRANSPORT_PUSH_OPTIONS)
454445
transport->push_options = push_options;
455446
if (push_with_options(transport, push_refspec, flags))

builtin/remote.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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.v[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;
@@ -1294,8 +1293,7 @@ static int show(int argc, const char **argv, const char *prefix)
12941293
get_remote_ref_states(*argv, &info.states, query_flag);
12951294

12961295
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)"));
1296+
printf_ln(_(" Fetch URL: %s"), info.states.remote->url.v[0]);
12991297
url = push_url_of_remote(info.states.remote);
13001298
for (i = 0; i < url->nr; i++)
13011299
/*
@@ -1440,10 +1438,7 @@ static int prune_remote(const char *remote, int dry_run)
14401438
}
14411439

14421440
printf_ln(_("Pruning %s"), remote);
1443-
printf_ln(_("URL: %s"),
1444-
states.remote->url.nr
1445-
? states.remote->url.v[0]
1446-
: _("(no URL)"));
1441+
printf_ln(_("URL: %s"), states.remote->url.v[0]);
14471442

14481443
for_each_string_list_item(item, &states.stale)
14491444
string_list_append(&refs_to_prune, item->util);
@@ -1632,8 +1627,6 @@ static int get_url(int argc, const char **argv, const char *prefix)
16321627
}
16331628

16341629
url = push_mode ? push_url_of_remote(remote) : &remote->url;
1635-
if (!url->nr)
1636-
die(_("no URLs configured for remote '%s'"), remotename);
16371630

16381631
if (all_mode) {
16391632
for (i = 0; i < url->nr; i++)

t/helper/test-bundle-uri.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ static int cmd_ls_remote(int argc, const char **argv)
8888
die(_("bad repository '%s'"), dest);
8989
die(_("no remote configured to get bundle URIs from"));
9090
}
91-
if (!remote->url.nr)
92-
die(_("remote '%s' has no configured URL"), dest);
9391

9492
transport = transport_get(remote, NULL);
9593
if (transport_get_remote_bundle_uri(transport) < 0) {

transport.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ static struct transport_vtable builtin_smart_vtable = {
11121112
struct transport *transport_get(struct remote *remote, const char *url)
11131113
{
11141114
const char *helper;
1115+
const char *p;
11151116
struct transport *ret = xcalloc(1, sizeof(*ret));
11161117

11171118
ret->progress = isatty(2);
@@ -1127,19 +1128,15 @@ struct transport *transport_get(struct remote *remote, const char *url)
11271128
ret->remote = remote;
11281129
helper = remote->foreign_vcs;
11291130

1130-
if (!url && remote->url.nr)
1131+
if (!url)
11311132
url = remote->url.v[0];
11321133
ret->url = url;
11331134

1134-
/* maybe it is a foreign URL? */
1135-
if (url) {
1136-
const char *p = url;
1137-
1138-
while (is_urlschemechar(p == url, *p))
1139-
p++;
1140-
if (starts_with(p, "::"))
1141-
helper = xstrndup(url, p - url);
1142-
}
1135+
p = url;
1136+
while (is_urlschemechar(p == url, *p))
1137+
p++;
1138+
if (starts_with(p, "::"))
1139+
helper = xstrndup(url, p - url);
11431140

11441141
if (helper) {
11451142
transport_helper_init(ret, helper);

0 commit comments

Comments
 (0)