From f9127561461fe209171aaf81afd2bbe234756d7b Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 4 Sep 2005 01:37:25 +0200 Subject: [PATCH] translate reference into hash while reading a commit --- gitweb.cgi | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gitweb.cgi b/gitweb.cgi index 94063aaa1..6a61c6555 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -478,7 +478,16 @@ sub git_read_commit { if (!defined $co{'tree'}) { return undef }; - $co{'id'} = $commit_id; + if (!($commit_id =~ m/^[0-9a-fA-F]{40}$/)) { + # lookup hash by textual id + open my $fd, "-|", "$gitbin/git-rev-parse --verify $commit_id" or return; + my $hash_id = <$fd>; + close $fd or return; + chomp $hash_id; + $co{'id'} = $hash_id + } else { + $co{'id'} = $commit_id; + } $co{'parents'} = \@parents; $co{'parent'} = $parents[0]; $co{'comment'} = \@commit_lines; @@ -1630,7 +1639,7 @@ sub git_commit { "\n"; print "committer" . escapeHTML($co{'committer'}) . "\n"; print " $cd{'rfc2822'}" . sprintf(" (%02d:%02d %s)", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . "\n"; - print "commit$hash\n"; + print "commit$co{'id'}\n"; print "" . "tree" . "" . -- 2.30.2