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

Re: [PATCH 2/3] gitweb: Cache $parent_commit info in git_blame()

From
LTLuben Tuikov <ltuikov@yahoo.com>
Date
Dec 10, 2008, 06:20 UTC
Message-ID
<182871.96175.qm@web31804.mail.mud.yahoo.com>
In-Reply-To
<20081209224622.28106.89325.stgit@localhost.localdomain>
--- On Tue, 12/9/08, Jakub Narebski <jnareb@gmail.com> wrote:
Show 14 quoted lines
> From: Jakub Narebski <jnareb@gmail.com>
> Subject: [PATCH 2/3] gitweb: Cache $parent_commit info in git_blame()
> To: git@vger.kernel.org
> Cc: "Luben Tuikov" <ltuikov@yahoo.com>, "Jakub Narebski" <jnareb@gmail.com>
> Date: Tuesday, December 9, 2008, 2:48 PM
> Luben Tuikov changed 'lineno' link from leading to
> commit which lead
> to current version of given block of lines, to leading to
> parent of
> this commit in 244a70e (Blame "linenr" link jumps
> to previous state at
> "orig_lineno").  This supposedly made data mining
> possible (or just
> better).

Before 244a70e, clicking on linenr links would display the same commit id as displayed to the left, which is no different than the block of lines displayed, thus data mining was impossible, i.e. I had to manually (commands) go back in history to see how this line or block of lines developed and/or changed.

244a70e didn't make data mining perfect, just possible.
Show 5 quoted lines
> This patch attempts to migitate issue a bit by caching
> $parent_commit
> info in %metainfo, which makes gitweb to call git-rev-parse
> only once
> per unique commit in blame output.

Have you tested this patch that it gives the same commit chain as before it?

   Luben
Show 5 quoted lines
> 
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> That is what I have noticed during browsing git_blame()
> code.
What?
> We can change it to even more effective implementation
> (like the ones
> proposed above in the commit message) later.
Where?
Show 38 quoted lines
> 
> Indenting is cause for artifically large diff
> 
>  gitweb/gitweb.perl |   16 +++++++++++-----
>  1 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 1b800f4..916396a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -4657,11 +4657,17 @@ HTML
>  			              esc_html($rev));
>  			print "</td>\n";
>  		}
> -		open (my $dd, "-|", git_cmd(),
> "rev-parse", "$full_rev^")
> -			or die_error(500, "Open git-rev-parse
> failed");
> -		my $parent_commit = <$dd>;
> -		close $dd;
> -		chomp($parent_commit);
> +		my $parent_commit;
> +		if (!exists $meta->{'parent'}) {
> +			open (my $dd, "-|", git_cmd(),
> "rev-parse", "$full_rev^")
> +				or die_error(500, "Open git-rev-parse
> failed");
> +			$parent_commit = <$dd>;
> +			close $dd;
> +			chomp($parent_commit);
> +			$meta->{'parent'} = $parent_commit;
> +		} else {
> +			$parent_commit = $meta->{'parent'};
> +		}
>  		my $blamed = href(action => 'blame',
>  		                  file_name =>
> $meta->{'filename'},
>  		                  hash_base => $parent_commit);
Previous: Junio C HamanoNext: Jakub Narebski
Message 16 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.