Re: [PATCH 3/3] gitweb: A bit of code cleanup in git_blame()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 10, 2008, 08:35 UTC
- Message-ID
- <7voczk1l7q.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <ghn8jv$hg9$1@ger.gmane.org>
Jakub Narebski <jnareb@gmail.com> writes:
Show 13 quoted lines
> Jakub Narebski wrote:
>
> I'm sorry, there should be
>
> + my $ftype = "blob";
>> if (!defined $hash) {
>> $hash = git_get_hash_by_path($hash_base, $file_name, "blob")
>> or die_error(404, "Error looking up file");
>> + } else {
>> + $ftype = git_get_type($hash);
>> + if ($ftype !~ "blob") {
>> + die_error(400, "Object is not a blob");
>> + }I will squash in the following and queue [1/3] and [3/3] to 'pu', as there seem to be a few comments on [2/3] that look worth addressing.
gitweb/gitweb.perl | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git c/gitweb/gitweb.perl w/gitweb/gitweb.perl index d491a1d..ccbf5d4 100755 --- c/gitweb/gitweb.perl +++ w/gitweb/gitweb.perl @@ -4585,11 +4585,12 @@ sub git_blame { die_error(404, "Couldn't find base commit") unless $hash_base; my %co = parse_commit($hash_base) or die_error(404, "Commit not found"); + my $ftype = "blob"; if (!defined $hash) { $hash = git_get_hash_by_path($hash_base, $file_name, "blob") or die_error(404, "Error looking up file"); } else { - my $ftype = git_get_type($hash); + $ftype = git_get_type($hash); if ($ftype !~ "blob") { die_error(400, "Object is not a blob"); } @@ -4637,7 +4638,8 @@ HTML $metainfo{$full_rev} = {}; } my $meta = $metainfo{$full_rev}; - while (my $data = <$fd>) { + my $data; + while ($data = <$fd>) { chomp $data; last if ($data =~ s/^\t//); # contents of line if ($data =~ /^(\S+) (.*)$/) {