]> Lady’s Gitweb - Gitweb/commit
gitweb: Incremental blame (using JavaScript)
authorJakub Narebski <redacted>
Tue, 1 Sep 2009 11:39:17 +0000 (13:39 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
commite1f26f013c4ee3a9ce54f62889ead084998e5e9a11e79ddeb7fe33235cfde1b0
tree37b51f3f7a9d951598e5c1ed692f48ee45797531dfa87c226cbda5aca5adc7bd
parente546798785150d144b0d1d8048ecdf8573383eb92ae6d16fb0c3217040ca4a8d
gitweb: Incremental blame (using JavaScript)

Add 'blame_incremental' view, which uses "git blame --incremental"
and JavaScript (Ajax), where 'blame' use "git blame --porcelain".

 * gitweb generates initial info by putting file contents (from
   "git cat-file") together with line numbers in blame table
 * then gitweb makes web browser JavaScript engine call startBlame()
   function from gitweb.js
 * startBlame() opens XMLHttpRequest connection to 'blame_data' view,
   which in turn calls "git blame --incremental" for a file, and
   streams output of git-blame to JavaScript (gitweb.js)
 * XMLHttpRequest event handler updates line info in blame view as soon
   as it gets data from 'blame_data' (from server), and it also updates
   progress info
 * when 'blame_data' ends, and gitweb.js finishes updating line info,
   it fixes colors to match (as far as possible) ordinary 'blame' view,
   and updates information about how long it took to generate page.

Gitweb deals with streamed 'blame_data' server errors by displaying
them in the progress info area (just in case).

The 'blame_incremental' view tries to be equivalent to 'blame' action;
there are however a few differences in output between 'blame' and
'blame_incremental' view:

 * 'blame_incremental' always used query form for this part of link(s)
   which is generated by JavaScript code.  The difference is visible
   if we use path_info link (pass some or all arguments in path_info).
   Changing this would require implementing something akin to href()
   subroutine from gitweb.perl in JavaScript (in gitweb.js).
 * 'blame_incremental' always uses "rowspan" attribute, even if
   rowspan="1".  This simplifies code, and is not visible to user.
 * The progress bar and progress info are still there even after
   JavaScript part of 'blame_incremental' finishes work.

Note that currently no link generated by gitweb leads to this new view.

This code is based on patch by Petr Baudis <redacted> patch, which
in turn was tweaked up version of Fredrik Kuivinen <redacted>'s
proof of concept patch.

This patch adds GITWEB_JS compile configuration option, and modifies
git-instaweb.sh to take gitweb.js into account.  The code for
git-instaweb.sh was taken from Pasky's patch.

Signed-off-by: Fredrik Kuivinen <redacted>
Signed-off-by: Petr Baudis <redacted>
Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
README
gitweb.css
gitweb.js [new file with mode: 0644]
gitweb.perl
This page took 0.264677 seconds and 4 git commands to generate.