Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHan-Wen Nienhuys2017-03-07 18:14:27 +0000
committerHan-Wen Nienhuys2017-03-29 11:51:37 +0000
commit6e652846f64a2e4af0b31c96f52bd86f6fc43e7e (patch)
tree36bba88736d0c210a3b9afbba5e61b46a3fb9116
parent27b05c7d719754427a97c141b44bec7de3acb8db (diff)
downloadjgit-6e652846f64a2e4af0b31c96f52bd86f6fc43e7e.tar.gz
jgit-6e652846f64a2e4af0b31c96f52bd86f6fc43e7e.tar.xz
jgit-6e652846f64a2e4af0b31c96f52bd86f6fc43e7e.zip
Noop changes to ManifestParser
* Parse the base URL in ManifestParser construction. This will signal errors earlier. * Simplify stripping of trailing slashes. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Change-Id: I4a86f68c9d7737f71cf20352cfe26288fbd2b463
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java21
1 files changed, 7 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
index 7b600ee060..bfa5fbafd5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
@@ -78,7 +78,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public class ManifestParser extends DefaultHandler {
private final String filename;
- private final String baseUrl;
+ private final URI baseUrl;
private final String defaultBranch;
private final Repository rootRepo;
private final Map<String, Remote> remotes;
@@ -126,11 +126,11 @@ public class ManifestParser extends DefaultHandler {
this.defaultBranch = defaultBranch;
this.rootRepo = rootRepo;
- // Strip trailing /s to match repo behavior.
- int lastIndex = baseUrl.length() - 1;
- while (lastIndex >= 0 && baseUrl.charAt(lastIndex) == '/')
- lastIndex--;
- this.baseUrl = baseUrl.substring(0, lastIndex + 1);
+ // Strip trailing '/' to match repo behavior.
+ while (baseUrl.endsWith("/")) { //$NON-NLS-1$
+ baseUrl = baseUrl.substring(0, baseUrl.length()-1);
+ }
+ this.baseUrl = URI.create(baseUrl);
plusGroups = new HashSet<>();
minusGroups = new HashSet<>();
@@ -259,12 +259,6 @@ public class ManifestParser extends DefaultHandler {
// Only do the following after we finished reading everything.
Map<String, String> remoteUrls = new HashMap<>();
- URI baseUri;
- try {
- baseUri = new URI(baseUrl);
- } catch (URISyntaxException e) {
- throw new SAXException(e);
- }
if (defaultRevision == null && defaultRemote != null) {
Remote remote = remotes.get(defaultRemote);
if (remote != null) {
@@ -296,8 +290,7 @@ public class ManifestParser extends DefaultHandler {
}
String remoteUrl = remoteUrls.get(remote);
if (remoteUrl == null) {
- remoteUrl =
- baseUri.resolve(remotes.get(remote).fetch).toString();
+ remoteUrl = baseUrl.resolve(remotes.get(remote).fetch).toString();
if (!remoteUrl.endsWith("/")) //$NON-NLS-1$
remoteUrl = remoteUrl + "/"; //$NON-NLS-1$
remoteUrls.put(remote, remoteUrl);

Back to the top