Check parentFile is not null

parentFile becomes null when f is relative path, such as ".".

This patch avoids NullPointerException in such case.

Change-Id: I4752674b1daab6eedd7c3650c7749462810eaffd
Signed-off-by: Hiroshi Tomita <tomykaira@gmail.com>
This commit is contained in:
Hiroshi Tomita 2013-07-05 09:04:00 +09:00 committed by Matthias Sohn
parent 27c1c51079
commit 781b0b5735
1 changed files with 1 additions and 1 deletions

View File

@ -475,7 +475,7 @@ private static boolean isSamePrefix(String a, String b) {
private void removeEmptyParents(File f) {
File parentFile = f.getParentFile();
while (!parentFile.equals(repo.getWorkTree())) {
while (parentFile != null && !parentFile.equals(repo.getWorkTree())) {
if (!parentFile.delete())
break;
parentFile = parentFile.getParentFile();