git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 04/10] gitweb: Mark commits with no "previous" in 'blame' view

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 24, 2009, 22:44 UTC
Message-ID
<1248475450-5668-5-git-send-email-jnareb@gmail.com>
In-Reply-To
<1248475450-5668-1-git-send-email-jnareb@gmail.com>

Use "no-previous" class to mark blamed commits which do not have "previous" header. Those are commits in which blamed file was created (added); this includes boundary commits. This means that 'linenr' link leads to blamed commit, not (one of) parent of blamed commit. Therefore currently line number for such commit uses bold weight font to denote this situation; the effect is subtle.

Use "multiple-previous" class in the opposite situation, where blamed commit has multiple "previous" headers (is an evil merge). Currently this class is not used for styling. In this situation 'linenr' link leads to first of "previous" commits (first parent).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is new commit, which didn't appear in v1 of this series.

It does what marking "boundary" commit meant to do: it marks (via admittedly quite subtle change of style) "linenr" links which lead to 'blame' view at blamed commit, not at parent commit (because there is no parent commit).

This patch is after one using "previous" header for finding parents for "linenr" links, because it also uses (still undocumented) "previous" header.

 gitweb/gitweb.css  |    3 ++-
 gitweb/gitweb.perl |    7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index f47709b..4763337 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -242,7 +242,8 @@ tr.dark:hover {
 	background-color: #edece6;
 }
 
-tr.boundary td.sha1 {
+tr.boundary td.sha1,
+tr.no-previous td.linenr {
 	font-weight: bold;
 }
 
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b8a121b..128bddd 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4819,7 +4819,7 @@ HTML
 		my ($full_rev, $orig_lineno, $lineno, $group_size) =
 		   ($line =~ /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/);
 		if (!exists $metainfo{$full_rev}) {
-			$metainfo{$full_rev} = {};
+			$metainfo{$full_rev} = { 'nprevious' => 0 };
 		}
 		my $meta = $metainfo{$full_rev};
 		my $data;
@@ -4829,6 +4829,9 @@ HTML
 			if ($data =~ /^(\S+)(?: (.*))?$/) {
 				$meta->{$1} = $2 unless exists $meta->{$1};
 			}
+			if ($data =~ /^previous /) {
+				$meta->{'nprevious'}++;
+			}
 		}
 		my $short_rev = substr($full_rev, 0, 8);
 		my $author = $meta->{'author'};
@@ -4840,6 +4843,8 @@ HTML
 		}
 		my $tr_class = $rev_color[$current_color];
 		$tr_class .= ' boundary' if (exists $meta->{'boundary'});
+		$tr_class .= ' no-previous' if ($meta->{'nprevious'} == 0);
+		$tr_class .= ' multiple-previous' if ($meta->{'nprevious'} > 1);
 		print "<tr id=\"l$lineno\" class=\"$tr_class\">\n";
 		if ($group_size) {
 			print "<td class=\"sha1\"";
-- 
1.6.3.3
Previous: Jakub NarebskiNext: Jakub Narebski
Message 8 of 21 in “[PATCHv2 00/10] gitweb: 'blame' view improvements”
  1. Jakub NarebskiJul 24, 2009
  2. 01/10 gitweb: Make .error style genericJakub Narebski, Jul 24, 2009
  3. 02/10 gitweb: Mark boundary commits in 'blame' viewJakub Narebski, Jul 24, 2009
  4. Junio C HamanoJul 25, 2009
  5. Jakub NarebskiJul 25, 2009
  6. Junio C HamanoJul 25, 2009
  7. 03/10 gitweb: Use "previous" header of git-blame -p in 'blame' viewJakub Narebski, Jul 24, 2009
  8. 04/10 gitweb: Mark commits with no "previous" in 'blame' viewJakub Narebski, Jul 24, 2009
  9. 05/10 gitweb: Add author initials in 'blame' view, a la "git gui blame"Jakub Narebski, Jul 24, 2009
  10. 06/10 gitweb: Use light/dark for class names also in 'blame' viewJakub Narebski, Jul 24, 2009
  11. 07/10 gitweb: Add -partial_query option to href() subroutineJakub Narebski, Jul 24, 2009
  12. 08/10 gitweb: Add optional "time to generate page" info in footerJakub Narebski, Jul 24, 2009
  13. 09/10 gitweb: Incremental blame (proof of concept)Jakub Narebski, Jul 24, 2009
  14. Jakub NarebskiJul 25, 2009
  15. 10/10 gitweb: Create links leading to 'blame_incremental' using JavaScriptJakub Narebski, Jul 24, 2009
  16. Martin KoeglerJul 25, 2009
  17. Jakub NarebskiJul 26, 2009
  18. Martin KoeglerJul 27, 2009
  19. Jakub NarebskiJul 27, 2009
  20. Junio C HamanoJul 24, 2009
  21. Jakub NarebskiJul 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.