git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/3] gitweb: Link to 7-char+ SHA1s, not only 8-char+

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 6, 2016, 19:44 UTC
Message-ID
<xmqq37k9jm86.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161006091135.29590-3-avarab@gmail.com>
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 21 quoted lines
> Change the minimum length of an abbreviated object identifier in the
> commit message gitweb tries to turn into link from 8 hexchars to 7.
>
> This arbitrary minimum length of 8 was introduced in bfe2191 ("gitweb:
> SHA-1 in commit log message links to "object" view", 2006-12-10), but
> the default abbreviation length is 7, and has been for a long time.
>
> 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 ("first working version",
> 2005-08-07). Git will accept all-caps SHA1s, but didn't ever produce
> them as far as I can tell.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
s/SHA1/SHA-1/g.  I agree that A-F are dubious.
Show 16 quoted lines
>  gitweb/gitweb.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index cba7405..92b5e91 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;
Previous: Ævar Arnfjörð BjarmasonNext: Jakub Narębski
Message 11 of 16 in “gitweb: Be smarter about linking to SHA1s in log messages”
  1. 0/3 gitweb: Be smarter about linking to SHA1s in log messagesÆvar Arnfjörð Bjarmason, Oct 6, 2016
  2. 1/3 gitweb: Fix a typo in a commentÆvar Arnfjörð Bjarmason, Oct 6, 2016
  3. Jakub NarębskiOct 14, 2016
  4. 3/3 gitweb: Link to "git describe"'d commits in log messagesÆvar Arnfjörð Bjarmason, Oct 6, 2016
  5. Junio C HamanoOct 6, 2016
  6. Ævar Arnfjörð BjarmasonOct 9, 2016
  7. Ævar Arnfjörð BjarmasonOct 14, 2016
  8. Junio C HamanoOct 14, 2016
  9. Jakub NarębskiOct 14, 2016
  10. 2/3 gitweb: Link to 7-char+ SHA1s, not only 8-char+Ævar Arnfjörð Bjarmason, Oct 6, 2016
  11. Junio C HamanoOct 6, 2016
  12. Jakub NarębskiOct 14, 2016
  13. Junio C HamanoOct 14, 2016
  14. Ævar Arnfjörð BjarmasonOct 15, 2016
  15. Junio C HamanoOct 17, 2016
  16. Ævar Arnfjörð BjarmasonOct 17, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.