From 0078c2b7816bcfc32078226e263ce346926014d0 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 12 Jun 2013 17:18:11 -0400
Subject: [PATCH] Workaround incomplete blame commit dara (issue-254)
---
releases.moxie | 4 +++-
src/main/java/com/gitblit/models/AnnotatedLine.java | 13 ++++++++++---
src/main/java/com/gitblit/wicket/pages/BlamePage.java | 24 ++++++++++++++++--------
3 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/releases.moxie b/releases.moxie
index 197013a..f419992 100644
--- a/releases.moxie
+++ b/releases.moxie
@@ -28,7 +28,9 @@
- Ensure Redmine url is properly formatted (issue 223)
- Use standard ServletRequestWrapper instead of custom wrapper (issue 224)
- Switch commit message back to a pre and ensure that it is properly escaped when combined with commit message regex substitution (issue 242)
+ - Fixed AddIndexedBranch tool --branch parameter (issue 247)
- Improve NPE handling for hook script enumeration (issue-253)
+ - Workaround missing commit information in blame page (JGit bug 374382, issue-254)
changes:
- Improved error logging for servlet containers which provide a null contextFolder (issue 199)
@@ -82,7 +84,7 @@
- Lukasz Jader
- Martijn Laan
- Matthias Bauer
- - Micha�l Pailloncy
+ - Micha�l Pailloncy
- Michael Schaefers
- Philip Boutros
- Rafael Cavazin
diff --git a/src/main/java/com/gitblit/models/AnnotatedLine.java b/src/main/java/com/gitblit/models/AnnotatedLine.java
index 69b55bc..439a322 100644
--- a/src/main/java/com/gitblit/models/AnnotatedLine.java
+++ b/src/main/java/com/gitblit/models/AnnotatedLine.java
@@ -18,6 +18,7 @@
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 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 74e25be..5148915 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.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 @@
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 @@
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;
--
Gitblit v1.9.1