Merge branch 'stable-5.1'
* stable-5.1: SubmoduleValidator: Remove unused import of ConfigConstants SubmoduleValidator: Permit missing path or url Change-Id: Ie0e35231c81a0c53c2051c4c123a5210b5a1c6d3 Signed-off-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
commit
18dce03a41
|
@ -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 static void assertValidSubmoduleUri(String uri)
|
|||
*/
|
||||
public static void assertValidSubmodulePath(String path)
|
||||
throws SubmoduleValidationException {
|
||||
|
||||
if (path.startsWith("-")) { //$NON-NLS-1$
|
||||
throw new SubmoduleValidationException(
|
||||
MessageFormat.format(
|
||||
|
@ -154,19 +156,21 @@ public static void assertValidGitModulesFile(String gitModulesContents)
|
|||
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(
|
||||
|
|
Loading…
Reference in New Issue