From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit, gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command
---
src/com/gitblit/utils/DiffUtils.java | 36 ++++++++++++++++++++++++++----------
1 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/src/com/gitblit/utils/DiffUtils.java b/src/com/gitblit/utils/DiffUtils.java
index beeb532..04b5b0b 100644
--- a/src/com/gitblit/utils/DiffUtils.java
+++ b/src/com/gitblit/utils/DiffUtils.java
@@ -25,7 +25,7 @@
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.diff.RawText;
import org.eclipse.jgit.diff.RawTextComparator;
-import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTree;
@@ -48,6 +48,9 @@
private static final Logger LOGGER = LoggerFactory.getLogger(DiffUtils.class);
+ /**
+ * Enumeration for the diff output types.
+ */
public static enum DiffOutputType {
PLAIN, GITWEB, GITBLIT;
@@ -144,10 +147,15 @@
RevTree commitTree = commit.getTree();
RevTree baseTree;
if (baseCommit == null) {
- final RevWalk rw = new RevWalk(repository);
- RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
- rw.dispose();
- baseTree = parent.getTree();
+ if (commit.getParentCount() > 0) {
+ final RevWalk rw = new RevWalk(repository);
+ RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
+ rw.dispose();
+ baseTree = parent.getTree();
+ } else {
+ // FIXME initial commit. no parent?!
+ baseTree = commitTree;
+ }
} else {
baseTree = baseCommit.getTree();
}
@@ -205,9 +213,14 @@
RevTree commitTree = commit.getTree();
RevTree baseTree;
if (baseCommit == null) {
- final RevWalk rw = new RevWalk(repository);
- RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
- baseTree = parent.getTree();
+ if (commit.getParentCount() > 0) {
+ final RevWalk rw = new RevWalk(repository);
+ RevCommit parent = rw.parseCommit(commit.getParent(0).getId());
+ baseTree = parent.getTree();
+ } else {
+ // FIXME initial commit. no parent?!
+ baseTree = commitTree;
+ }
} else {
baseTree = baseCommit.getTree();
}
@@ -243,12 +256,15 @@
public static List<AnnotatedLine> blame(Repository repository, String blobPath, String objectId) {
List<AnnotatedLine> lines = new ArrayList<AnnotatedLine>();
try {
+ ObjectId object;
if (StringUtils.isEmpty(objectId)) {
- objectId = Constants.HEAD;
+ object = JGitUtils.getDefaultBranch(repository);
+ } else {
+ object = repository.resolve(objectId);
}
BlameCommand blameCommand = new BlameCommand(repository);
blameCommand.setFilePath(blobPath);
- blameCommand.setStartCommit(repository.resolve(objectId));
+ blameCommand.setStartCommit(object);
BlameResult blameResult = blameCommand.call();
RawText rawText = blameResult.getResultContents();
int length = rawText.size();
--
Gitblit v1.9.1