]> source.dussan.org Git - jgit.git/commitdiff
Fix non-relative remote defined in manifest xml. 48/31148/3
authorYuxuan 'fishy' Wang <fishywang@google.com>
Thu, 7 Aug 2014 01:17:29 +0000 (18:17 -0700)
committerYuxuan 'fishy' Wang <fishywang@google.com>
Thu, 7 Aug 2014 05:26:17 +0000 (22:26 -0700)
Currently if the remote defined in repo manifest xml is non-relative (e.g.
"https://chromium.googlesource.com"), our code will break. This change fixed
that.

It also makes that remotes are ending with "/".

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

index 12d4d311f3874f838f7bf0446a72fa3699c793eb..d8e4c1f9ee6743aa1e5022ac1c37b67e724cad2b 100644 (file)
@@ -420,15 +420,22 @@ public class RepoCommand extends GitCommand<RevCommit> {
                        }
                        final String remoteUrl;
                        try {
-                               URI uri = new URI(baseUrl);
-                               remoteUrl = uri.resolve(remotes.get(defaultRemote)).toString();
+                               URI uri = new URI(remotes.get(defaultRemote));
+                               if (uri.getHost() != null) {
+                                       // This is not relative path, no need for baseUrl.
+                                       remoteUrl = uri.toString();
+                               } else {
+                                       uri = new URI(baseUrl);
+                                       remoteUrl = uri.resolve(
+                                                       remotes.get(defaultRemote)).toString();
+                               }
                        } catch (URISyntaxException e) {
                                throw new SAXException(e);
                        }
                        removeNotInGroup();
                        removeOverlaps();
                        for (Project proj : projects) {
-                               command.addSubmodule(remoteUrl + proj.name,
+                               command.addSubmodule(remoteUrl + "/" + proj.name,
                                                proj.path,
                                                proj.revision == null
                                                                ? defaultRevision : proj.revision,