Skip to content

Commit 3665e7e

Browse files
jnarebgitster
authored andcommitted
gitweb: Mark commits with no "previous" in 'blame' view
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>
1 parent 1193042 commit 3665e7e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

gitweb/gitweb.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ tr.dark:hover {
242242
background-color: #edece6;
243243
}
244244

245-
tr.boundary td.sha1 {
245+
tr.boundary td.sha1,
246+
tr.no-previous td.linenr {
246247
font-weight: bold;
247248
}
248249

gitweb/gitweb.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4819,7 +4819,7 @@ sub git_blame {
48194819
my ($full_rev, $orig_lineno, $lineno, $group_size) =
48204820
($line =~ /^([0-9a-f]{40}) (\d+) (\d+)(?: (\d+))?$/);
48214821
if (!exists $metainfo{$full_rev}) {
4822-
$metainfo{$full_rev} = {};
4822+
$metainfo{$full_rev} = { 'nprevious' => 0 };
48234823
}
48244824
my $meta = $metainfo{$full_rev};
48254825
my $data;
@@ -4829,6 +4829,9 @@ sub git_blame {
48294829
if ($data =~ /^(\S+)(?: (.*))?$/) {
48304830
$meta->{$1} = $2 unless exists $meta->{$1};
48314831
}
4832+
if ($data =~ /^previous /) {
4833+
$meta->{'nprevious'}++;
4834+
}
48324835
}
48334836
my $short_rev = substr($full_rev, 0, 8);
48344837
my $author = $meta->{'author'};
@@ -4840,6 +4843,8 @@ sub git_blame {
48404843
}
48414844
my $tr_class = $rev_color[$current_color];
48424845
$tr_class .= ' boundary' if (exists $meta->{'boundary'});
4846+
$tr_class .= ' no-previous' if ($meta->{'nprevious'} == 0);
4847+
$tr_class .= ' multiple-previous' if ($meta->{'nprevious'} > 1);
48434848
print "<tr id=\"l$lineno\" class=\"$tr_class\">\n";
48444849
if ($group_size) {
48454850
print "<td class=\"sha1\"";

0 commit comments

Comments
 (0)