diff options
author | Jonathan Nieder <jrn@google.com> | 2018-10-08 21:49:09 +0000 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2018-10-08 21:49:09 +0000 |
commit | 830e0d6b8ce4bd1ab33142b63f2edf780438c5bc (patch) | |
tree | f46d7c20b9b0a138343cc949ded6a2d04e984861 | |
parent | f6eb78555195f5c0f011e7af6f284a745a5eb366 (diff) | |
parent | d3eaf1007b42048bd507ee5634af571863b8e21d (diff) | |
download | jgit-830e0d6b8ce4bd1ab33142b63f2edf780438c5bc.tar.gz jgit-830e0d6b8ce4bd1ab33142b63f2edf780438c5bc.zip |
Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
SubmoduleValidator: Permit missing path or url
Change-Id: I94fdaf45abbf7665f9eddc14b1a7f7144aafeadf
Signed-off-by: Jonathan Nieder <jrn@google.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/submodule/SubmoduleValidator.java | 27 |
1 files changed, 16 insertions, 11 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..5f405044c9 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,6 +42,10 @@ */ 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; @@ -134,7 +138,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 +157,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( |