]> Lady’s Gitweb - Gitweb/commit
gitweb: Refactor diff body line classification
authorJakub Narebski <redacted>
Sun, 30 Oct 2011 23:36:20 +0000 (00:36 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
commit4578f9e1ba9fd2d88d07cf3c1054bee4aa0b49c59a2f2acb685b0ef2730bdd09
treefc91721ed4f6a1470013df747846b28b644733a44ec2067d29ea89e82e71e754
parent76f96eed36acd357f20478c20a4ce19fae72a59b882aa1efaccd681d54290cd5
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 <redacted>
Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
This page took 0.197245 seconds and 4 git commands to generate.