aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Myers2011-11-04 09:42:12 (EDT)
committerMatthias Sohn2011-11-04 09:42:12 (EDT)
commit85a9ab7410c464a95d1951b381bee4d4e294fff7 (patch)
tree3862da247192cf392b13f71d20b09abfaf8f5783
parent2efbcb7e44bffb3b98548e153118e361befa1639 (diff)
downloadjgit-85a9ab7410c464a95d1951b381bee4d4e294fff7.zip
jgit-85a9ab7410c464a95d1951b381bee4d4e294fff7.tar.gz
jgit-85a9ab7410c464a95d1951b381bee4d4e294fff7.tar.bz2
Fix NPE when PATH environment variable is emptyrefs/changes/28/4528/5
Change-Id: Ic27d509cd5e2d6c855e7d355fc308399d9dc01c9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java13
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 7440fc9..ac8d655 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);