summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-09-27 14:28:27 -0400
committerJames Moger <james.moger@gitblit.com>2013-09-27 21:33:34 -0400
commitb384a9923314ef0ab7ec0e9f506c8d52cc31f5fc (patch)
tree5cb64d4b5982c69037c370096152c1e56711995e /src/main
parentb325021c4e3168ef77bf3eb28be1d4c834595de8 (diff)
downloadgitblit-b384a9923314ef0ab7ec0e9f506c8d52cc31f5fc.tar.gz
gitblit-b384a9923314ef0ab7ec0e9f506c8d52cc31f5fc.zip
Fix width calculation in branch graph when there are 0 or 1 commits
Change-Id: I68ed7e4db32fa69a13979b544e80edf3212555cd
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/gitblit/BranchGraphServlet.java52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/main/java/com/gitblit/BranchGraphServlet.java b/src/main/java/com/gitblit/BranchGraphServlet.java
index f46b8e6f..05c3c658 100644
--- a/src/main/java/com/gitblit/BranchGraphServlet.java
+++ b/src/main/java/com/gitblit/BranchGraphServlet.java
@@ -154,31 +154,34 @@ public class BranchGraphServlet extends HttpServlet {
commitList.fillTo(2*Math.max(requestedCommits, maxCommits));
// determine the appropriate width for the image
- int numLanes = 0;
+ int numLanes = 1;
int numCommits = Math.min(requestedCommits, commitList.size());
- Set<String> parents = new TreeSet<String>();
- for (int i = 0; i < commitList.size(); i++) {
- PlotCommit<Lane> commit = commitList.get(i);
- boolean checkLane = false;
-
- if (i < numCommits) {
- // commit in visible list
- checkLane = true;
-
- // remember parents
- for (RevCommit p : commit.getParents()) {
- parents.add(p.getName());
+ if (numCommits > 1) {
+ // determine graph width
+ Set<String> parents = new TreeSet<String>();
+ for (int i = 0; i < commitList.size(); i++) {
+ PlotCommit<Lane> commit = commitList.get(i);
+ boolean checkLane = false;
+
+ if (i < numCommits) {
+ // commit in visible list
+ checkLane = true;
+
+ // remember parents
+ for (RevCommit p : commit.getParents()) {
+ parents.add(p.getName());
+ }
+ } else if (parents.contains(commit.getName())) {
+ // commit outside visible list, but it is a parent of a
+ // commit in the visible list so we need to know it's lane
+ // assignment
+ checkLane = true;
+ }
+
+ if (checkLane) {
+ int pos = commit.getLane().getPosition();
+ numLanes = Math.max(numLanes, pos + 1);
}
- } else if (parents.contains(commit.getName())) {
- // commit outside visible list, but it is a parent of a
- // commit in the visible list so we need to know it's lane
- // assignment
- checkLane = true;
- }
-
- if (checkLane) {
- int pos = commit.getLane().getPosition();
- numLanes = Math.max(numLanes, pos + 1);
}
}
@@ -187,6 +190,7 @@ public class BranchGraphServlet extends HttpServlet {
// create an image buffer and render the lanes
BufferedImage image = new BufferedImage(graphWidth, rowHeight*numCommits, BufferedImage.TYPE_INT_ARGB);
+
Graphics2D g = null;
try {
g = image.createGraphics();
@@ -211,7 +215,7 @@ public class BranchGraphServlet extends HttpServlet {
// write the image buffer to the client
response.setContentType("image/png");
- if (numCommits > 0) {
+ if (numCommits > 1) {
response.setHeader("Cache-Control", "public, max-age=60, must-revalidate");
response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commitList.get(0)).getTime());
}