Tom
2014-10-26 df0ba7f7ff02ed02c0ba7714ae928a79d932baef
refs
author Tom <tw201207@gmail.com>
Sunday, October 26, 2014 13:10 -0400
committer Tom <tw201207@gmail.com>
Thursday, November 6, 2014 12:05 -0500
commitdf0ba7f7ff02ed02c0ba7714ae928a79d932baef
tree daf72f5876cffec0b185276bd86a7060bd7f9391 tree | zip | gz
parent 02c6a8c24505625c5f411c0af1019c7c1f443d07 view | diff
Improve the commitdiff.

* Optimize CSS: simplify selectors. That alone cuts rendering time in
half!
* Adapt HTML generation accordingly.
* Change line number generation so that one can select only code lines.
Also move the +/- out of the code column; it also gets in the way
when selecting.
* Omit long diffs altogether.
* Omit diff lines for deleted files, they're not particularly
interesting.
* Introduce a global limit on the maximum number of diff lines to show.
* Supply translations for the languages I speak for the new messages.

https://code.google.com/p/gitblit/issues/detail?id=450 was about a diff
with nearly 300k changed lines (with more then 3000 files deleted). But
one doesn't have to have such a monster commit to run into problems. My
FF 32 become unresponsive for the 30+ seconds it takes it to render a
commitdiff with some 30000 changed lines. (90% of which are in two
generated files; the whole commit has just 20 files.) GitHub has no
problems showing a commitdiff for this commit, but omits the two large
generated files, which makes sense.

This change implements a similar thing. Files with too many diff lines
get omitted from the output, only the header and a message that the
diff is too large remains. Additionally, there's a global limit on
the length of a commitdiff; if we exceed that, the whole diff is
truncated and the files not shown are listed.

The CSS change improves performance by not using descendant selectors
for all these table cells. Instead, we assign them precise classes and
just use that in the CSS.

The line number generation thing using data attributes and a :before
selector in the CSS, which enables text selections only in the code
column, is not strictly XHTML 1.0. (Data attributes are a feature of
HTML 5.) However, reasonably modern browsers also handle this correctly
if the page claims to be XHTML 1.0. Besides, the commitdiff page isn't
XHTML compliant anyway; I don't think a pre-element may contain divs
or even tables.

(Note that this technique could be used on other diff pages, too. For
instance on the blame page.)
1 files added
6 files modified
870 ■■■■■ changed files
src/main/java/com/gitblit/utils/DiffUtils.java 7 ●●●●● diff | view | raw | blame | history
src/main/java/com/gitblit/utils/GitBlitDiffFormatter.java 709 ●●●●● diff | view | raw | blame | history
src/main/java/com/gitblit/utils/ResettableByteArrayOutputStream.java 42 ●●●●● diff | view | raw | blame | history
src/main/java/com/gitblit/wicket/GitBlitWebApp.properties 9 ●●●● diff | view | raw | blame | history
src/main/java/com/gitblit/wicket/GitBlitWebApp_de.properties 7 ●●●●● diff | view | raw | blame | history
src/main/java/com/gitblit/wicket/GitBlitWebApp_fr.properties 7 ●●●●● diff | view | raw | blame | history
src/main/resources/gitblit.css 89 ●●●● diff | view | raw | blame | history