James Moger
2013-09-27 b384a9923314ef0ab7ec0e9f506c8d52cc31f5fc
Fix width calculation in branch graph when there are 0 or 1 commits

Change-Id: I68ed7e4db32fa69a13979b544e80edf3212555cd
1 files modified
8 ■■■■ changed files
src/main/java/com/gitblit/BranchGraphServlet.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/BranchGraphServlet.java
@@ -154,8 +154,10 @@
            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());
            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);
@@ -181,12 +183,14 @@
                    numLanes = Math.max(numLanes, pos + 1);
                }
            }
            }
            int graphWidth = numLanes * LANE_WIDTH + RIGHT_PAD;
            int rowHeight = ROW_HEIGHT;
            // 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 @@
            // 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());
            }