From b82e4bf7719e75eda2c3e60cdae593a7bd8f6979 Mon Sep 17 00:00:00 2001 From: Jens Baumgart Date: Wed, 9 Feb 2011 15:12:31 +0100 Subject: [PATCH] Fix NPE on reading global config on MAC Bug: 336610 Change-Id: Iefcb85e791723801faa315b3ee45fb19e3ca52fb Signed-off-by: Jens Baumgart --- org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index e69596313..14fac15df 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@ -66,7 +66,12 @@ abstract class FS_POSIX extends FS { String w = readPipe(userHome(), // new String[] { "bash", "--login", "-c", "which git" }, // Charset.defaultCharset().name()); - return new File(w).getParentFile().getParentFile(); + if (w == null || w.length() == 0) + return null; + File parentFile = new File(w).getParentFile(); + if (parentFile == null) + return null; + return parentFile.getParentFile(); } return null;