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

Re: [PATCH] Add git-annotate - a tool for annotating files with the revision and person that created each line in the file.

From
RARyan Anderson <ryan@michonline.com>
Date
Feb 10, 2006, 22:04 UTC
Message-ID
<20060210220445.GD456@mythryan2.michonline.com>
In-Reply-To
<7vlkwlo788.fsf@assigned-by-dhcp.cox.net>
On Wed, Feb 08, 2006 at 01:45:11PM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> Ryan Anderson <ryan@michonline.com> writes:
> 
> >> It's been a while since I looked at it the last time so it may
> >> not even work with the current git, but here it is..
> >
> > I'll take a look through this in greater detail later, hopefully your
> > approach can be applied.  Diff-analyzing is apparently tricky.
> 
> Reading diff is tricky but I was lazy to match up the lines by
> hand, which is also a real work ;-).

Reading a diff is tricky, yes, but if you're willing to just throw RAM at the problem, it might not be quite as bad as I was trying at first.

My current thought on how to get it more correct is this:
	foreach $rev (@revqueue) {
		foreach $parent (@{$revs{$rev}{parents}}) {
			my @templines = @{$revs{$rev}{lines}};
			$revs{$parent}{lines} = apply_diff(\@templlines);
		}
	}

The @lines arrays that get built will be entirely made up of hash or array references, so they just get reused for each successive file.

When apply_diff() deletes a line from the new copy, it should mark that line as "claimed" by the current rev.

I'm thinking that each element of @lines will look like this:
	{
		text => $text,
		in_original => [0 | 1],
		claimed_by => $rev,
	}
at least to start.

This method can sanity check itself by calling git cat-file and actually reading in each version of the file, and comparing it against the generated copy, aborting if we get the two out of sync.

I'll see about implementing something along these lines this weekend, time permitting.

-- 
Ryan Anderson
  sometimes Pug Majere
Previous: Junio C Hamano
Message 19 of 19 in “Add git-annotate - a tool for annotating files with the revision and person that created each line in the file.”
  1. Add git-annotate - a tool for annotating files with the revision and person that created each line in the file.Ryan Anderson, Feb 8, 2006
  2. Peter EriksenFeb 8, 2006
  3. Johannes SchindelinFeb 8, 2006
  4. Franck Bui-HuuFeb 8, 2006
  5. Johannes SchindelinFeb 8, 2006
  6. Junio C HamanoFeb 8, 2006
  7. Ralf BaechleFeb 10, 2006
  8. Andreas EricssonFeb 10, 2006
  9. Fredrik KuivinenFeb 14, 2006
  10. Randal L. SchwartzFeb 8, 2006
  11. Andreas EricssonFeb 9, 2006
  12. Junio C HamanoFeb 9, 2006
  13. Franck Bui-HuuFeb 9, 2006
  14. Andreas EricssonFeb 9, 2006
  15. Linus TorvaldsFeb 8, 2006
  16. Junio C HamanoFeb 8, 2006
  17. Ryan AndersonFeb 8, 2006
  18. Junio C HamanoFeb 8, 2006
  19. Ryan AndersonFeb 10, 2006

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.