Skip to contentSkip to conversation

gitweb: Incremental blame

PATCH In review Petr Baudis 1 participant 2 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Incremental blame

This is tweaked up version of Fredrik Kuivinen <[email protected]>'s proof of concept patch to add support for incrementally displaying line data in the blame view using some javascript gadgetry.

The original patch has been lightly tested in a couple of browsers (Firefox, Mozilla, Konqueror, Galeon, Opera and IE6). The new patch has been tested in Firefox and Epiphany (and works fine in Epiphany 2.14.3, contrary to what the original patch claimed).

Compared to the original patch, this one works with pathinfo-ish URLs as well, and should play well with non-javascript browsers as well (the HTML points to the blame action, while javascript code rewrites the links to use the blame_incremental action; it is somewhat hackish but I couldn't think of a better solution).

As usual, you can see it in action at repo.or.cz. blame view now feels a lot more friendly.

Cc Fredrik Kuivinen <[email protected]>

---

 Makefile           |    6 +-
 git-instaweb.sh    |    7 ++
 gitweb/blame.js    |  193 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gitweb/gitweb.perl |  140 +++++++++++++++++++++++++++++++++++---
 4 files changed, 335 insertions(+), 11 deletions(-)
Makefile +5 -1
index ed12577..46a9fcb 100644
@@ -168,6 +168,7 @@ GITWEB_HOMETEXT = indextext.html
 GITWEB_CSS = gitweb.css
 GITWEB_LOGO = git-logo.png
 GITWEB_FAVICON = git-favicon.png
+GITWEB_BLAMEJS = blame.js
 GITWEB_SITE_HEADER =
 GITWEB_SITE_FOOTER =
 
@@ -815,13 +816,14 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 	    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 	    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
+	    -e 's|++GITWEB_BLAMEJS++|$(GITWEB_BLAMEJS)|g' \
 	    -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 	    -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 	    $< >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 
-git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
+git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/blame.js
 	$(QUIET_GEN)rm -f $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
@@ -830,6 +832,8 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 	    -e '/@@GITWEB_CGI@@/d' \
 	    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
 	    -e '/@@GITWEB_CSS@@/d' \
+	    -e '/@@GITWEB_BLAMEJS@@/r gitweb/blame.js' \
+	    -e '/@@GITWEB_BLAMEJS@@/d' \
 	    [email protected] > $@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
git-instaweb.sh +7 -0
index cbc7418..dddbb6b 100755
@@ -233,8 +233,15 @@ gitweb_css () {
 EOFGITWEB
 }
 
+gitweb_blamejs () {
+	cat > "$1" <<\EOFGITWEB
+@@GITWEB_BLAMEJS@@
+EOFGITWEB
+}
+
 gitweb_cgi $GIT_DIR/gitweb/gitweb.cgi
 gitweb_css $GIT_DIR/gitweb/gitweb.css
+gitweb_blamejs $GIT_DIR/gitweb/blame.js
 
 case "$httpd" in
 *lighttpd*)
gitweb/blame.js new file +193 -0

193 lines not on this page · raw message

gitweb/gitweb.perl +130 -10

224 lines not on this page · raw message

#1 lore raw
Quoted 5 lines · Petr Baudis

Compared to the original patch, this one works with pathinfo-ish URLs as well, and should play well with non-javascript browsers as well (the HTML points to the blame action, while javascript code rewrites the links to use the blame_incremental action; it is somewhat hackish but I couldn't think of a better solution).

To make it more clear, the additional changes in this patch are really totally trivial (except the link rewriting javascript code, which is rather simple too and I spent only two happy hours of my life debugging it) - maybe I should've kept Fredrik signed off and maybe even the patch author and add just my signoff. I'm not really sure how the procedures should work here.

Signature · 5 lines
		Petr "Pasky the I HATE THE
			!@#*($!*(^%@#*$233.. JAVASCRIPT!!!!!!!!" Baudis
Stuff: http://pasky.or.cz/
Ever try. Ever fail. No matter. // Try again. Fail again. Fail better.
		-- Samuel Beckett