commitList.fillTo(2*Math.max(requestedCommits, maxCommits));\r
\r
// determine the appropriate width for the image\r
- int numLanes = 0;\r
+ int numLanes = 1;\r
int numCommits = Math.min(requestedCommits, commitList.size());\r
- Set<String> parents = new TreeSet<String>();\r
- for (int i = 0; i < commitList.size(); i++) {\r
- PlotCommit<Lane> commit = commitList.get(i);\r
- boolean checkLane = false;\r
- \r
- if (i < numCommits) {\r
- // commit in visible list\r
- checkLane = true;\r
- \r
- // remember parents\r
- for (RevCommit p : commit.getParents()) {\r
- parents.add(p.getName());\r
+ if (numCommits > 1) {\r
+ // determine graph width\r
+ Set<String> parents = new TreeSet<String>();\r
+ for (int i = 0; i < commitList.size(); i++) {\r
+ PlotCommit<Lane> commit = commitList.get(i);\r
+ boolean checkLane = false;\r
+\r
+ if (i < numCommits) {\r
+ // commit in visible list\r
+ checkLane = true;\r
+\r
+ // remember parents\r
+ for (RevCommit p : commit.getParents()) {\r
+ parents.add(p.getName());\r
+ }\r
+ } else if (parents.contains(commit.getName())) {\r
+ // commit outside visible list, but it is a parent of a\r
+ // commit in the visible list so we need to know it's lane\r
+ // assignment\r
+ checkLane = true;\r
+ }\r
+\r
+ if (checkLane) {\r
+ int pos = commit.getLane().getPosition();\r
+ numLanes = Math.max(numLanes, pos + 1);\r
}\r
- } else if (parents.contains(commit.getName())) {\r
- // commit outside visible list, but it is a parent of a\r
- // commit in the visible list so we need to know it's lane\r
- // assignment\r
- checkLane = true;\r
- }\r
- \r
- if (checkLane) {\r
- int pos = commit.getLane().getPosition();\r
- numLanes = Math.max(numLanes, pos + 1);\r
}\r
}\r
\r
\r
// create an image buffer and render the lanes\r
BufferedImage image = new BufferedImage(graphWidth, rowHeight*numCommits, BufferedImage.TYPE_INT_ARGB);\r
+ \r
Graphics2D g = null;\r
try {\r
g = image.createGraphics();\r
\r
// write the image buffer to the client\r
response.setContentType("image/png");\r
- if (numCommits > 0) {\r
+ if (numCommits > 1) {\r
response.setHeader("Cache-Control", "public, max-age=60, must-revalidate");\r
response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commitList.get(0)).getTime());\r
}\r