When the 'url' parameter was absolute, the previous implementation would
concatenate 'remote_url' with 'url'. Instead, we want to return 'url' in
this case.
The documentation now discusses what happens when supplying two
absolute URLs.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
int is_relative = 0;
int colonsep = 0;
char *out;
- char *remoteurl = xstrdup(remote_url);
+ char *remoteurl;
struct strbuf sb = STRBUF_INIT;
- size_t len = strlen(remoteurl);
+ size_t len;
+
+ if (!url_is_local_not_ssh(url) || is_absolute_path(url))
+ return xstrdup(url);
+
+ len = strlen(remote_url);
+ if (!len)
+ BUG("invalid empty remote_url");
+ remoteurl = xstrdup(remote_url);
if (is_dir_sep(remoteurl[len-1]))
remoteurl[len-1] = '\0';
* http://a.com/b ../../../c http:/c error out
* http://a.com/b ../../../../c http:c error out
* http://a.com/b ../../../../../c .:c error out
+ * http://a.com/b http://d.org/e http://d.org/e as is
* NEEDSWORK: Given how chop_last_dir() works, this function is broken
* when a local part has a colon in its path component, too.
*/