]> source.dussan.org Git - jgit.git/commitdiff
Fix NPE when PATH environment variable is empty 28/4528/5
authorCarl Myers <cmyers@palantir.com>
Fri, 4 Nov 2011 13:42:12 +0000 (14:42 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Fri, 4 Nov 2011 13:42:12 +0000 (14:42 +0100)
Change-Id: Ic27d509cd5e2d6c855e7d355fc308399d9dc01c9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java

index 7440fc9d1fe625ae48b9c0281a9c3c6f4d43f0d9..ac8d65501561e63045266acf13207454a4ba8fe8 100644 (file)
@@ -244,7 +244,20 @@ public abstract class FS {
                return new File(home).getAbsoluteFile();
        }
 
+       /**
+        * Searches the given path to see if it contains one of the given files.
+        * Returns the first it finds. Returns null if not found or if path is null.
+        *
+        * @param path
+        *            List of paths to search separated by File.pathSeparator
+        * @param lookFor
+        *            Files to search for in the given path
+        * @return the first match found, or null
+        **/
        static File searchPath(final String path, final String... lookFor) {
+               if (path == null)
+                       return null;
+
                for (final String p : path.split(File.pathSeparator)) {
                        for (String command : lookFor) {
                                final File e = new File(p, command);