summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2018-10-08 23:41:15 +0000
committerJonathan Nieder <jrn@google.com>2018-10-08 23:41:15 +0000
commite63ca8d09432efbc35c5b5884aba7702be2cd7f0 (patch)
treeb0d5f020c21e52bbf1d10aed7c8b1e5d02c80651
parent3e73672c06c3c369449c1463a869d31004957fcc (diff)
parenteb41de5b2534f07f1164bbb7ad1a19b225b55e7f (diff)
downloadjgit-e63ca8d09432efbc35c5b5884aba7702be2cd7f0.tar.gz
jgit-e63ca8d09432efbc35c5b5884aba7702be2cd7f0.zip
Merge branch 'stable-4.11' into stable-5.0
* stable-4.11: SubmoduleValidator: Remove unused import of ConfigConstants SubmoduleValidator: Permit missing path or url Change-Id: Iaf3b994e763bd02054b820cd87fe68ff83675001 Signed-off-by: Jonathan Nieder <jrn@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java
index d4bba2d0d1..3651631573 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java
@@ -42,13 +42,16 @@
*/
package org.eclipse.jgit.internal.submodule;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PATH;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_URL;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_SUBMODULE_SECTION;
+
import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.Config;
-import org.eclipse.jgit.lib.ConfigConstants;
/**
* Validations for the git submodule fields (name, path, uri).
@@ -134,7 +137,6 @@ public class SubmoduleValidator {
*/
public static void assertValidSubmodulePath(String path)
throws SubmoduleValidationException {
-
if (path.startsWith("-")) { //$NON-NLS-1$
throw new SubmoduleValidationException(
MessageFormat.format(
@@ -154,19 +156,21 @@ public class SubmoduleValidator {
Config c = new Config();
try {
c.fromText(gitModulesContents);
- for (String subsection : c.getSubsections(
- ConfigConstants.CONFIG_SUBMODULE_SECTION)) {
- String url = c.getString(
- ConfigConstants.CONFIG_SUBMODULE_SECTION,
- subsection, ConfigConstants.CONFIG_KEY_URL);
- assertValidSubmoduleUri(url);
-
+ for (String subsection :
+ c.getSubsections(CONFIG_SUBMODULE_SECTION)) {
assertValidSubmoduleName(subsection);
+ String url = c.getString(
+ CONFIG_SUBMODULE_SECTION, subsection, CONFIG_KEY_URL);
+ if (url != null) {
+ assertValidSubmoduleUri(url);
+ }
+
String path = c.getString(
- ConfigConstants.CONFIG_SUBMODULE_SECTION, subsection,
- ConfigConstants.CONFIG_KEY_PATH);
- assertValidSubmodulePath(path);
+ CONFIG_SUBMODULE_SECTION, subsection, CONFIG_KEY_PATH);
+ if (path != null) {
+ assertValidSubmodulePath(path);
+ }
}
} catch (ConfigInvalidException e) {
throw new IOException(