diff options
author | Carl Myers <cmyers@palantir.com> | 2011-11-04 14:42:12 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2011-11-04 14:42:12 +0100 |
commit | 85a9ab7410c464a95d1951b381bee4d4e294fff7 (patch) | |
tree | 3862da247192cf392b13f71d20b09abfaf8f5783 | |
parent | 2efbcb7e44bffb3b98548e153118e361befa1639 (diff) | |
download | jgit-85a9ab7410c464a95d1951b381bee4d4e294fff7.tar.gz jgit-85a9ab7410c464a95d1951b381bee4d4e294fff7.zip |
Fix NPE when PATH environment variable is empty
Change-Id: Ic27d509cd5e2d6c855e7d355fc308399d9dc01c9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 7440fc9d1f..ac8d655015 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -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); |