summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-06-12 17:18:11 -0400
committerJames Moger <james.moger@gitblit.com>2013-06-12 17:18:11 -0400
commit0078c2b7816bcfc32078226e263ce346926014d0 (patch)
tree6b0c5889a1a4e314e2e3c3a702e7411f3897e167 /src/main/java
parent9788200234dfe222989823c6160d2be40fd84415 (diff)
downloadgitblit-0078c2b7816bcfc32078226e263ce346926014d0.tar.gz
gitblit-0078c2b7816bcfc32078226e263ce346926014d0.zip
Workaround incomplete blame commit dara (issue-254)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/gitblit/models/AnnotatedLine.java13
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BlamePage.java24
2 files changed, 26 insertions, 11 deletions
diff --git a/src/main/java/com/gitblit/models/AnnotatedLine.java b/src/main/java/com/gitblit/models/AnnotatedLine.java
index 69b55bcd..439a3222 100644
--- a/src/main/java/com/gitblit/models/AnnotatedLine.java
+++ b/src/main/java/com/gitblit/models/AnnotatedLine.java
@@ -18,6 +18,7 @@ package com.gitblit.models;
import java.io.Serializable;
import java.util.Date;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
/**
@@ -38,9 +39,15 @@ public class AnnotatedLine implements Serializable {
public final String data;
public AnnotatedLine(RevCommit commit, int lineNumber, String data) {
- this.commitId = commit.getName();
- this.author = commit.getAuthorIdent().getName();
- this.when = commit.getAuthorIdent().getWhen();
+ if (commit == null) {
+ this.commitId = ObjectId.zeroId().getName();
+ this.author = "?";
+ this.when = new Date(0);
+ } else {
+ this.commitId = commit.getName();
+ this.author = commit.getAuthorIdent().getName();
+ this.when = commit.getAuthorIdent().getWhen();
+ }
this.lineNumber = lineNumber;
this.data = data;
}
diff --git a/src/main/java/com/gitblit/wicket/pages/BlamePage.java b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
index 74e25be0..51489150 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlamePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
@@ -27,6 +27,7 @@ import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.GitBlit;
@@ -96,6 +97,7 @@ public class BlamePage extends RepositoryPage {
private int count;
private String lastCommitId = "";
private boolean showInitials = true;
+ private String zeroId = ObjectId.zeroId().getName();
public void populateItem(final Item<AnnotatedLine> item) {
AnnotatedLine entry = item.getModelObject();
@@ -105,14 +107,20 @@ public class BlamePage extends RepositoryPage {
if (!lastCommitId.equals(entry.commitId)) {
lastCommitId = entry.commitId;
count++;
- // show the link for first line
- LinkPanel commitLink = new LinkPanel("commit", null,
- getShortObjectId(entry.commitId), CommitPage.class,
- newCommitParameter(entry.commitId));
- WicketUtils.setHtmlTooltip(commitLink,
- MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when)));
- item.add(commitLink);
- showInitials = true;
+ if (zeroId.equals(entry.commitId)) {
+ // unknown commit
+ item.add(new Label("commit", "<?>"));
+ showInitials = false;
+ } else {
+ // show the link for first line
+ LinkPanel commitLink = new LinkPanel("commit", null,
+ getShortObjectId(entry.commitId), CommitPage.class,
+ newCommitParameter(entry.commitId));
+ WicketUtils.setHtmlTooltip(commitLink,
+ MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when)));
+ item.add(commitLink);
+ showInitials = true;
+ }
} else {
if (showInitials) {
showInitials = false;