gitweb: Refactor diff body line classification
commita8754c4fd9a2aae39bb3bad8bbc654b2090d8e7e
authorJakub Narebski <jnareb@gmail.com>
Sat, 22 Oct 2011 13:10:46 +0000 (22 15:10 +0200)
committerJakub Narebski <jnareb@gmail.com>
Sat, 22 Oct 2011 13:10:46 +0000 (22 15:10 +0200)
treee764929b8b4d7cded8a70ce3251b34f4203d657d
parent8963314c77af9a4eda5dcbdbab3d4001af83ad81
gitweb: Refactor diff body line classification

Simplify classification of diff line body in format_diff_line(),
replacing two if-elsif chains (one for ordinary diff and one for
combined diff of a merge commit) with regexp match.  Refactor this
code into diff_line_class() function.

While at it:

* Fix an artifact in that $diff_class included leading space to be
  able to compose classes like this "class=\"diff$diff_class\"', even
  when $diff_class was an empty string.  This made code unnecessary
  ugly: $diff_class is now just class name or an empty string.

* Introduce "ctx" class for context lines ($diff_class was set to ""
  in this case before this commit).

Idea and initial code by Junio C Hamano, polish and testing by Jakub
Narebski.  Inspired by patch adding side-by-side diff by Kato Kazuyoshi,
which required $diff_class to be name of class without extra space.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
gitweb/gitweb.perl