int pageSize = request.getParameter("pageSize") != null ? new Integer(request.getParameter("pageSize")).intValue() : Integer.MAX_VALUE; //$NON-NLS-1$ //$NON-NLS-2$
int start = pageSize * (page - 1);
int end = Math.min(pageSize + start, l.size());
int i = start;
for (i = start; i < end; i++) {
DiffEntry entr = l.get(i);
JSONObject diff = new JSONObject();
diff.put(ProtocolConstants.KEY_TYPE, org.eclipse.orion.server.git.objects.Diff.TYPE);
diff.put(GitConstants.KEY_COMMIT_DIFF_NEWPATH, entr.getNewPath());
diff.put(GitConstants.KEY_COMMIT_DIFF_OLDPATH, entr.getOldPath());
diff.put(GitConstants.KEY_COMMIT_DIFF_CHANGETYPE, entr.getChangeType().toString());
// add diff location for the commit
String path = entr.getChangeType() != ChangeType.DELETE ? entr.getNewPath() : entr.getOldPath();
diff.put(GitConstants.KEY_DIFF, createDiffLocation(diffLocation, path));
diff.put(ProtocolConstants.KEY_CONTENT_LOCATION, createContentLocation(cloneLocation, entr, path));
diffs.put(diff);
}