aboutsummaryrefslogtreecommitdiff
path: root/gitweb/gitweb.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-10-26 13:14:45 -0700
committerJunio C Hamano <gitster@pobox.com>2016-10-26 13:14:46 -0700
commit5b941872d6003976ba4a1adc92bbc4de774661a8 (patch)
tree3f09b83179fd995cefbb503103a0510a2698b2cc /gitweb/gitweb.perl
parent8e83d0531579da7abbfc603b5268995c2464efe8 (diff)
parentcf5c7253e0f8d19bdb981a41b2552b28e3f6e0e3 (diff)
downloadgit-5b941872d6003976ba4a1adc92bbc4de774661a8.tar.gz
git-5b941872d6003976ba4a1adc92bbc4de774661a8.tar.xz
Merge branch 'ab/gitweb-abbrev-links'
In addition to purely abbreviated commit object names, "gitweb" learned to turn "git describe" output (e.g. v2.9.3-599-g2376d31787) into clickable links in its output. * ab/gitweb-abbrev-links: gitweb: link to "git describe"'d commits in log messages gitweb: link to 7-char+ SHA-1s, not only 8-char+ gitweb: fix a typo in a comment
Diffstat (limited to 'gitweb/gitweb.perl')
-rwxr-xr-xgitweb/gitweb.perl20
1 files changed, 17 insertions, 3 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 44094f41d..7cf68f07b 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1616,7 +1616,7 @@ sub esc_path {
return $str;
}
-# Sanitize for use in XHTML + application/xml+xhtm (valid XML 1.0)
+# Sanitize for use in XHTML + application/xml+xhtml (valid XML 1.0)
sub sanitize {
my $str = shift;
@@ -2036,10 +2036,24 @@ sub format_log_line_html {
my $line = shift;
$line = esc_html($line, -nbsp=>1);
- $line =~ s{\b([0-9a-fA-F]{8,40})\b}{
+ $line =~ s{
+ \b
+ (
+ # The output of "git describe", e.g. v2.10.0-297-gf6727b0
+ # or hadoop-20160921-113441-20-g094fb7d
+ (?<!-) # see strbuf_check_tag_ref(). Tags can't start with -
+ [A-Za-z0-9.-]+
+ (?!\.) # refs can't end with ".", see check_refname_format()
+ -g[0-9a-fA-F]{7,40}
+ |
+ # Just a normal looking Git SHA1
+ [0-9a-fA-F]{7,40}
+ )
+ \b
+ }{
$cgi->a({-href => href(action=>"object", hash=>$1),
-class => "text"}, $1);
- }eg;
+ }egx;
return $line;
}