]> source.dussan.org Git - jgit.git/commitdiff
Better way to handle relative URLs in manifest XML 87/28087/2
authorYuxuan 'fishy' Wang <fishywang@google.com>
Fri, 6 Jun 2014 00:25:34 +0000 (17:25 -0700)
committerYuxuan 'fishy' Wang <fishywang@google.com>
Fri, 6 Jun 2014 00:40:37 +0000 (17:40 -0700)
The old implementation will NOT strip the filename part from the baseUrl, e.g.
https://android.googlesource.com/platform/manifest with .. will be resolved to
https://android.googlesource.com/platform/, which is actually wrong. This
implementation will resolve it to https://android.googlesource.com/ to match the
behavior of repo.

Change-Id: Ia32c8b34e16eacdf37a0da7025bf0b5cc5f67ed2
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

index 0bcc9693885e11052d3a2e98408d7e32ca76e4ae..22ff066fc3aec8dbf8fb40113bcaf1020a406a3c 100644 (file)
@@ -351,8 +351,8 @@ public class RepoCommand extends GitCommand<RevCommit> {
                        }
                        final String remoteUrl;
                        try {
-                               URI uri = new URI(String.format("%s/%s/", baseUrl, remotes.get(defaultRemote))); //$NON-NLS-1$
-                               remoteUrl = uri.normalize().toString();
+                               URI uri = new URI(baseUrl);
+                               remoteUrl = uri.resolve(remotes.get(defaultRemote)).toString();
                        } catch (URISyntaxException e) {
                                throw new SAXException(e);
                        }