35
return (!!remote->url) || (!!remote->foreign_vcs);
36
}
37
38
-static const char *alias_url(const char *url, struct rewrites *r)
38
+static char *alias_url(const char *url, struct rewrites *r)
39
{
40
int i, j;
41
struct counted_string *longest;
56
}
57
}
58
if (!longest)
59
- return url;
59
+ return NULL;
60
61
return xstrfmt("%s%s", r->rewrite[longest_i]->base, url + longest->len);
62
}
76
static void add_pushurl_alias(struct remote_state *remote_state,
77
struct remote *remote, const char *url)
78
{
79
- const char *pushurl = alias_url(url, &remote_state->rewrites_push);
80
- if (pushurl != url)
81
- add_pushurl(remote, pushurl);
79
+ char *alias = alias_url(url, &remote_state->rewrites_push);
80
+ if (alias)
81
+ add_pushurl(remote, alias);
82
}
83
84
static void add_url_alias(struct remote_state *remote_state,
85
struct remote *remote, const char *url)
86
{
87
- add_url(remote, alias_url(url, &remote_state->rewrites));
87
+ char *alias = alias_url(url, &remote_state->rewrites);
88
+ add_url(remote, alias ? alias : url);
89
add_pushurl_alias(remote_state, remote, url);
90
}
91
493
if (!remote_state->remotes[i])
494
continue;
495
for (j = 0; j < remote_state->remotes[i]->pushurl_nr; j++) {
495
- remote_state->remotes[i]->pushurl[j] =
496
- alias_url(remote_state->remotes[i]->pushurl[j],
497
- &remote_state->rewrites);
496
+ char *alias = alias_url(remote_state->remotes[i]->pushurl[j],
497
+ &remote_state->rewrites);
498
+ if (alias)
499
+ remote_state->remotes[i]->pushurl[j] = alias;
500
}
501
add_pushurl_aliases = remote_state->remotes[i]->pushurl_nr == 0;
502
for (j = 0; j < remote_state->remotes[i]->url_nr; j++) {
503
+ char *alias;
504
if (add_pushurl_aliases)
505
add_pushurl_alias(
506
remote_state, remote_state->remotes[i],
507
remote_state->remotes[i]->url[j]);
505
- remote_state->remotes[i]->url[j] =
506
- alias_url(remote_state->remotes[i]->url[j],
508
+ alias = alias_url(remote_state->remotes[i]->url[j],
509
&remote_state->rewrites);
510
+ if (alias)
511
+ remote_state->remotes[i]->url[j] = alias;
512
}
513
}
514
}