diff options
-rw-r--r-- | src/main/java/com/gitblit/utils/JGitUtils.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index 212a90af..7621c0e0 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -704,6 +704,7 @@ public class JGitUtils { return null;
}
RevCommit commit = null;
+ RevWalk walk = null;
try {
// resolve object id
ObjectId branchObject;
@@ -712,12 +713,18 @@ public class JGitUtils { } else {
branchObject = repository.resolve(objectId);
}
- RevWalk walk = new RevWalk(repository);
+ if (branchObject == null) {
+ return null;
+ }
+ walk = new RevWalk(repository);
RevCommit rev = walk.parseCommit(branchObject);
commit = rev;
- walk.dispose();
} catch (Throwable t) {
error(t, repository, "{0} failed to get commit {1}", objectId);
+ } finally {
+ if (walk != null) {
+ walk.dispose();
+ }
}
return commit;
}
|