summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;