Skip to content

Commit

Permalink
gitweb: Mark commits with no "previous" in 'blame' view
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Jul 25, 2009
1 parent 1193042 commit 3665e7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gitweb/gitweb.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -4819,7 +4819,7 @@ sub git_blame {
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;
Expand All @@ -4829,6 +4829,9 @@ sub git_blame {
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'};
Expand All @@ -4840,6 +4843,8 @@ sub git_blame {
}
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\"";
Expand Down

0 comments on commit 3665e7e

Please sign in to comment.