[PATCH 2/3] gitweb: Link to 7-character SHA1SUMS in commit messages
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Sep 21, 2016, 11:44 UTC
- Message-ID
- <20160921114428.28664-2-avarab@gmail.com>
- In-Reply-To
- <20160921114428.28664-1-avarab@gmail.com>
Change the minimum length of a commit we'll link to from 8 to 7.
This arbitrary minimum length of 8 was introduced in v1.4.4.2-151-gbfe2191, but as seen in e.g. v1.7.4-1-gdce9648 the default abbreviation length is 7.
It's still possible to reference SHA1s down to 4 characters in length, see v1.7.4-1-gdce9648's MINIMUM_ABBREV, but I can't see how to make git actually produce that, so I doubt anyone is putting that into log messages in practice, but people definitely do put 7 character SHA1s into log messages.
I think it's fairly dubious to link to things matching [0-9a-fA-F] here as opposed to just [0-9a-f], that dates back to the initial version of gitweb from 161332a. Git will accept all-caps SHA1s, but didn't ever produce them as far as I can tell. --- gitweb/gitweb.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 9473daf..101dbc0 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2036,7 +2036,7 @@ 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([0-9a-fA-F]{7,40})\b}{ $cgi->a({-href => href(action=>"object", hash=>$1), -class => "text"}, $1); }eg;
-- 2.1.3