]> source.dussan.org Git - jgit.git/commitdiff
Tweak the handling of remote url in jgit repo. 62/31562/1
authorYuxuan 'fishy' Wang <fishywang@google.com>
Wed, 13 Aug 2014 17:36:56 +0000 (10:36 -0700)
committerYuxuan 'fishy' Wang <fishywang@google.com>
Wed, 13 Aug 2014 17:36:56 +0000 (10:36 -0700)
This kind of reverted 31148. URI.resolve actually can handle the absolute URL
well, the problem is only the missing "/".

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

index d8e4c1f9ee6743aa1e5022ac1c37b67e724cad2b..57514a203d6c36a907bdfe4e9b84a5270eac89f2 100644 (file)
@@ -418,24 +418,19 @@ public class RepoCommand extends GitCommand<RevCommit> {
                                else
                                        throw new SAXException(RepoText.get().errorNoDefault);
                        }
-                       final String remoteUrl;
+                       String remoteUrl;
                        try {
-                               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();
-                               }
+                               URI uri = new URI(baseUrl);
+                               remoteUrl = uri.resolve(remotes.get(defaultRemote)).toString();
+                               if (!remoteUrl.endsWith("/"))
+                                       remoteUrl = remoteUrl + "/";
                        } 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,