|
|
@ -42,6 +42,10 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.eclipse.jgit.internal.submodule; |
|
|
|
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.io.IOException; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.MessageFormat; |
|
|
|
|
|
|
|
|
|
|
@ -134,7 +138,6 @@ public class SubmoduleValidator { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static void assertValidSubmodulePath(String path) |
|
|
|
public static void assertValidSubmodulePath(String path) |
|
|
|
throws SubmoduleValidationException { |
|
|
|
throws SubmoduleValidationException { |
|
|
|
|
|
|
|
|
|
|
|
if (path.startsWith("-")) { //$NON-NLS-1$
|
|
|
|
if (path.startsWith("-")) { //$NON-NLS-1$
|
|
|
|
throw new SubmoduleValidationException( |
|
|
|
throw new SubmoduleValidationException( |
|
|
|
MessageFormat.format( |
|
|
|
MessageFormat.format( |
|
|
@ -154,20 +157,22 @@ public class SubmoduleValidator { |
|
|
|
Config c = new Config(); |
|
|
|
Config c = new Config(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
c.fromText(gitModulesContents); |
|
|
|
c.fromText(gitModulesContents); |
|
|
|
for (String subsection : c.getSubsections( |
|
|
|
for (String subsection : |
|
|
|
ConfigConstants.CONFIG_SUBMODULE_SECTION)) { |
|
|
|
c.getSubsections(CONFIG_SUBMODULE_SECTION)) { |
|
|
|
|
|
|
|
assertValidSubmoduleName(subsection); |
|
|
|
|
|
|
|
|
|
|
|
String url = c.getString( |
|
|
|
String url = c.getString( |
|
|
|
ConfigConstants.CONFIG_SUBMODULE_SECTION, |
|
|
|
CONFIG_SUBMODULE_SECTION, subsection, CONFIG_KEY_URL); |
|
|
|
subsection, ConfigConstants.CONFIG_KEY_URL); |
|
|
|
if (url != null) { |
|
|
|
assertValidSubmoduleUri(url); |
|
|
|
assertValidSubmoduleUri(url); |
|
|
|
|
|
|
|
} |
|
|
|
assertValidSubmoduleName(subsection); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String path = c.getString( |
|
|
|
String path = c.getString( |
|
|
|
ConfigConstants.CONFIG_SUBMODULE_SECTION, subsection, |
|
|
|
CONFIG_SUBMODULE_SECTION, subsection, CONFIG_KEY_PATH); |
|
|
|
ConfigConstants.CONFIG_KEY_PATH); |
|
|
|
if (path != null) { |
|
|
|
assertValidSubmodulePath(path); |
|
|
|
assertValidSubmodulePath(path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} catch (ConfigInvalidException e) { |
|
|
|
} catch (ConfigInvalidException e) { |
|
|
|
throw new IOException( |
|
|
|
throw new IOException( |
|
|
|
MessageFormat.format( |
|
|
|
MessageFormat.format( |
|
|
|