From 357109c5a5518db5925f49a6700a87e7ed30ca14 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 28 Dec 2011 16:19:29 -0500
Subject: [PATCH] Unit testing. Documentation.
---
src/com/gitblit/utils/JGitUtils.java | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 31fd08f..d694ee2 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -471,6 +471,19 @@
}
/**
+ * Retrieves a Java Date from a Git commit.
+ *
+ * @param commit
+ * @return date of the commit or Date(0) if the commit is null
+ */
+ public static Date getAuthorDate(RevCommit commit) {
+ if (commit == null) {
+ return new Date(0);
+ }
+ return commit.getAuthorIdent().getWhen();
+ }
+
+ /**
* Returns the specified commit from the repository. If the repository does
* not exist or is empty, null is returned.
*
@@ -988,7 +1001,14 @@
RevWalk rw = new RevWalk(repository);
rw.markStart(rw.parseCommit(endRange));
- rw.markUninteresting(rw.parseCommit(startRange));
+ if (startRange.equals(ObjectId.zeroId())) {
+ // maybe this is a tag or an orphan branch
+ list.add(rw.parseCommit(endRange));
+ rw.dispose();
+ return list;
+ } else {
+ rw.markUninteresting(rw.parseCommit(startRange));
+ }
Iterable<RevCommit> revlog = rw;
for (RevCommit rev : revlog) {
--
Gitblit v1.9.1