gitweb: Refactor diff body line classification
commit20a864cd835d5d3f559c3cddf5ac5c259bd61171
authorJakub Narebski <jnareb@gmail.com>
Sun, 30 Oct 2011 23:36:20 +0000 (31 00:36 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 31 Oct 2011 22:22:55 +0000 (31 15:22 -0700)
tree587ea0b94985ee7561ff4326feea53a99114e07e
parentbe3fa9125e708348c7baf04ebe9507a72a9d1800
gitweb: Refactor diff body line classification

Simplify classification of diff line body in format_diff_line(),
replacing two long if-elsif chains (one for ordinary diff and one for
combined diff of a merge commit) with a single 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl