]> source.dussan.org Git - jgit.git/commitdiff
Require all projects to have a name 81/49981/3
authorJonathan Nieder <jrn@google.com>
Wed, 10 Jun 2015 23:35:43 +0000 (16:35 -0700)
committerJonathan Nieder <jrn@google.com>
Thu, 11 Jun 2015 17:44:18 +0000 (10:44 -0700)
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>
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java

index fa27948a64bf2c586bb3d352780df67314814901..891479d1f4eb994bc6f4c2e8b1349e417fb0f3f9 100644 (file)
@@ -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$
index 2c30e391b6a4d5b677d1e3a2233aed62fb729d1e..9a072114a7334bc53d0daeb402feca61cb8a4018 100644 (file)
@@ -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;