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

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+) (.*)$/) {
Previous: Jakub NarebskiNext: Luben Tuikov
Message 23 of 31 in “gitweb: Improve git_blame in preparation for incremental blame”
  1. 0/3 gitweb: Improve git_blame in preparation for incremental blameJakub Narebski, Dec 9, 2008
  2. 1/3 gitweb: Move 'lineno' id from link to row element in git_blameJakub Narebski, Dec 9, 2008
  3. Luben TuikovDec 10, 2008
  4. Petr BaudisDec 17, 2008
  5. 2/3 gitweb: Cache $parent_commit info in git_blame()Jakub Narebski, Dec 9, 2008
  6. Nanako ShiraishiDec 10, 2008
  7. Jakub NarebskiDec 10, 2008
  8. Junio C HamanoDec 10, 2008
  9. 2/3 gitweb: Cache $parent_commit info in git_blame()Jakub Narebski, Dec 11, 2008
  10. Luben TuikovDec 11, 2008
  11. Junio C HamanoDec 11, 2008
  12. Junio C HamanoDec 12, 2008
  13. Jakub NarebskiDec 12, 2008
  14. Petr BaudisDec 17, 2008
  15. Junio C HamanoDec 17, 2008
  16. Luben TuikovDec 10, 2008
  17. Jakub NarebskiDec 10, 2008
  18. Luben TuikovDec 10, 2008
  19. Jakub NarebskiDec 10, 2008
  20. Luben TuikovDec 10, 2008
  21. 3/3 gitweb: A bit of code cleanup in git_blame()Jakub Narebski, Dec 9, 2008
  22. Jakub NarebskiDec 10, 2008
  23. Junio C HamanoDec 10, 2008
  24. Luben TuikovDec 10, 2008
  25. 4/3 gitweb: Incremental blame (proof of concept)Jakub Narebski, Dec 10, 2008
  26. Junio C HamanoDec 11, 2008
  27. Jakub NarebskiDec 11, 2008
  28. Jakub NarebskiDec 11, 2008
  29. Jakub NarebskiDec 11, 2008
  30. gitweb: Incremental blame (proof of concept)Jakub Narebski, Dec 14, 2008
  31. [RFC] gitweb: Incremental blame - suggestions for improvementsJakub Narebski, Dec 14, 2008

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.