Browse Source

Require all projects to have a name

A project's name attribute is required according to repo's
doc/manifest-format.txt:

    <!ELEMENT project (annotation*,
                       project*)>
    <!ATTLIST project name        CDATA #REQUIRED>

Enforcing this in code makes reading easier (in particular making it
clearer that getName() and getPath() can never return null).

Change-Id: I8c7014dd6042183d7fecb2202af5acdc384aa8e4
Signed-off-by: Jonathan Nieder <jrn@google.com>
stable-4.1
Jonathan Nieder 10 years ago
parent
commit
85ca42f14b
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
  2. 3
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java

3
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java

@ -183,6 +183,9 @@ public class ManifestParser extends DefaultHandler {
String qName,
Attributes attributes) throws SAXException {
if ("project".equals(qName)) { //$NON-NLS-1$
if (attributes.getValue("name") == null) { //$NON-NLS-1$
throw new SAXException(RepoText.get().invalidManifest);
}
currentProject = new RepoProject(
attributes.getValue("name"), //$NON-NLS-1$
attributes.getValue("path"), //$NON-NLS-1$

3
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java

@ -138,6 +138,9 @@ public class RepoProject implements Comparable<RepoProject> {
*/
public RepoProject(String name, String path, String revision,
String remote, String groups) {
if (name == null) {
throw new NullPointerException();
}
this.name = name;
if (path != null)
this.path = path;

Loading…
Cancel
Save