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

Re: [PATCH 2/3] gitweb: Link to 7-character SHA1SUMS in commit messages

From
Jakub Narębski <jnareb@gmail.com>
Date
Sep 21, 2016, 16:26 UTC
Message-ID
<64389bcb-c6e4-1d19-54a1-650868b9acb5@gmail.com>
In-Reply-To
<20160921114428.28664-2-avarab@gmail.com>
W dniu 21.09.2016 o 13:44, Ævar Arnfjörð Bjarmason napisał:
> Subject: [PATCH 2/3] gitweb: Link to 7-character SHA1SUMS in commit messages

This is modification of a feature, not a new feature it sounds like. I think the following title / subject would be better:

  Subject: [PATCH 2/3] gitweb: Link to 7-char+ SHA1s, not only 8-char+
>
> Change the minimum length of a commit we'll link to from 8 to 7.
I think it would read better as:
  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
> v1.4.4.2-151-gbfe2191, but as seen in e.g. v1.7.4-1-gdce9648 the
> default abbreviation length is 7.
Right. I wonder why it was 8 in gitweb...
Show 6 quoted lines
> 
> 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.

There is an additional problem: the shorter SHA1 abbrev we try to match, the more possibility of false positives, words that only look like (shortened SHA-1).

For 7 characters there is at last one word that can be mistaken for SHA1 abbrev, namely 'deedeed' (hopefully rare in commit messages). For 6 characters we have 'accede', 'beaded', 'decade' (!), 'deface', 'facade' (!!), and possibly more (and of course all 7 character hexdigit words).

Also, the number of digits provided as an optional parameter to --abbrev or --abbrev-commit options is only a minimal number of hexdigits: Git would use as many as needed for the abbreviated SHA-1 to be unambiguous, at current time.

I think allowing 7-character shortened SHA-1, which is what Git produces for smaller repositories by default is (might be?) a good idea. Thanks for the patch.

Show 5 quoted lines
> 
> 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.
All right, thanks for reminder.
Signoff?
Show 18 quoted lines
> ---
>  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;
> 
Nice and simple.

P.S. I have reworking of commit message parsing and enhancement in my long, long and dated gitweb TODO list :-(

P.P.S. Kay Sievers no longer works on gitweb, and I think no longer works at SuSE but at RedHat.

Best,
-- 
Jakub Narębski
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 3 of 17 in “gitweb: Fix an ancient typo in v1.7.7-rc1-1-g0866786”
  1. 1/3 gitweb: Fix an ancient typo in v1.7.7-rc1-1-g0866786Ævar Arnfjörð Bjarmason, Sep 21, 2016
  2. 2/3 gitweb: Link to 7-character SHA1SUMS in commit messagesÆvar Arnfjörð Bjarmason, Sep 21, 2016
  3. Jakub NarębskiSep 21, 2016
  4. Ævar Arnfjörð BjarmasonSep 21, 2016
  5. Jakub NarębskiSep 21, 2016
  6. Ævar Arnfjörð BjarmasonSep 21, 2016
  7. 3/3 gitweb: Link to "git describe"'d commits in log messagesÆvar Arnfjörð Bjarmason, Sep 21, 2016
  8. Junio C HamanoSep 21, 2016
  9. Jakub NarębskiSep 21, 2016
  10. Junio C HamanoSep 21, 2016
  11. Jakub NarębskiSep 21, 2016
  12. Ævar Arnfjörð BjarmasonSep 21, 2016
  13. Jakub NarębskiSep 21, 2016
  14. Jakub NarębskiSep 21, 2016
  15. Ævar Arnfjörð BjarmasonSep 21, 2016
  16. Jakub NarębskiSep 21, 2016
  17. Ævar Arnfjörð BjarmasonSep 21, 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.