Merge branch 'tl/gitweb-shorten-hashes-with-modes' into jch
The object ID shortening and linking in the 'commitdiff' view of 'gitweb' has been corrected to work even when the index line carries a trailing file mode. * tl/gitweb-shorten-hashes-with-modes: gitweb: shorten index hashes with trailing file modesjch
commit
896d4857cd
|
|
@ -2339,12 +2339,14 @@ sub format_extended_diff_header_line {
|
|||
$line .= $cgi->a({-href=>$to->{'href'}, -class=>"path"},
|
||||
esc_path($to->{'file'}));
|
||||
}
|
||||
# match single <mode>
|
||||
if ($line =~ m/\s(\d{6})$/) {
|
||||
$line .= '<span class="info"> (' .
|
||||
file_type_long($1) .
|
||||
')</span>';
|
||||
|
||||
# Temporarily remove a trailing <mode> so an index line ends with its
|
||||
# object IDs and can be shortened below.
|
||||
my $mode;
|
||||
if ($line =~ s/\s(\d{6})$//) {
|
||||
$mode = $1;
|
||||
}
|
||||
|
||||
# match <hash>
|
||||
if ($line =~ oid_nlen_prefix_infix_regex($sha1_len, "index ", ",") |
|
||||
$line =~ oid_nlen_prefix_infix_regex($sha256_len, "index ", ",")) {
|
||||
|
|
@ -2388,6 +2390,12 @@ sub format_extended_diff_header_line {
|
|||
my ($from_id, $to_id) = ($diffinfo->{'from_id'}, $diffinfo->{'to_id'});
|
||||
$line =~ s!$from_id\.\.$to_id!$from_link..$to_link!;
|
||||
}
|
||||
if (defined $mode) {
|
||||
$line .= " $mode" .
|
||||
'<span class="info"> (' .
|
||||
file_type_long($mode) .
|
||||
')</span>';
|
||||
}
|
||||
|
||||
return $line . "<br/>\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,19 @@ test_expect_success 'snapshot: hierarchical branch name (xx/test)' '
|
|||
'
|
||||
test_debug 'cat gitweb.headers'
|
||||
|
||||
test_expect_success 'commitdiff: index line shortens hashes with mode' '
|
||||
old_blob=$(git rev-parse HEAD:foo) &&
|
||||
old_short=$(git rev-parse --short=7 HEAD:foo) &&
|
||||
echo changed >foo &&
|
||||
git commit -am "change foo" &&
|
||||
new_blob=$(git rev-parse HEAD:foo) &&
|
||||
new_short=$(git rev-parse --short=7 HEAD:foo) &&
|
||||
gitweb_run "p=.git;a=commitdiff;h=HEAD" &&
|
||||
test_grep ">${old_short}</a>\\.\\.<a [^>]*>${new_short}</a> 100644<span class=\"info\"> (file)</span>" \
|
||||
gitweb.body &&
|
||||
test_grep ! "index ${old_blob}\\.\\.${new_blob} 100644" gitweb.body
|
||||
'
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# forks of projects
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue