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

Re: [PATCH] Add git-annotate, a tool for assigning blame.

From
Junio C Hamano <junkio@cox.net>
Date
Feb 20, 2006, 22:54 UTC
Message-ID
<7virr98wvc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<11404323692193-git-send-email-ryan@michonline.com>
Ryan Anderson <ryan@michonline.com> writes:
> I would appreciate some other testing on this, as I can't find a case
> where it falls down, but the files with a lot of history tend to have a
> lot of lines, making them hard to spotcheck without having been an
> intimate part of that history.

I looked at a couple of files, including pack-objects.c, rev-list.c (in "pu"), and svnimport.perl; what I saw made sense. I think however we would want to check things with a lot of merges, so git repository may not be a good guinea pig.

> Oh, this is the "functional" version, but it might not qualify as "nice
> looking" yet, pleaes, feel free to complain.
Nice.
Two design glitches and an implementation:
 - You seem to rely on the working tree file to be clean relative to
   HEAD.
 - You do not take anything other than HEAD as the starting point.

Maybe an additional -r<this-version> option which defaults to HEAD, plus reading the blob always from that tree as the starting point would be helpful.

> +	open(P,"-|","git-rev-list","--parents","--remove-empty",$rev,"--",$file)

Johannes noticed I slipped this form which Perl 5.6 does not grok in another program. Eric pointed out he uses a backward compatible idiom in his code.

We would need to make this one safe; something like this, perhaps:
	sub open_read_pipe {
        	my ($fh, @cmd) = @_;
                my $pid = open($fh, '-|');
		die "$!" unless defined($pid);
		if (!$pid) {
			exec(@cmd) or die "$!";
		}
		return $fh;
	}
	...
        open_read_pipe(\*P, qw(git-rev-list --parents --remove-empty),
			$rev, '--', $file);
> +	open(P,"-|","git-diff-tree", "-M50", "-r","--name-status", "-z","$rev")
> +		or die "Failed to exec git-diff: $!";

If you do not mean "I want -M50" but you meant "I want whatever is default", I'd leave that 50 out.

It is probably premature to talk about issues for UI that can be built on top of this, but what I found interesting was this. While looking at the annotate output, whenever I got curious about one line ("Oh, this is an ancient change and by somebody who does not feed patches to git regularly -- what was the change about???"), I grabbed the SHA1 of the commit on the line and threw it at "git show". It was a good way to see how the change to the line was done in context. Maybe a two-pane UI that shows annotate on the top pane, and activating one line from it shows "git show" output on the bottom pane to show the commit log plus changes the commit introduced to the file and other files.

Previous: Ryan AndersonNext: Fredrik Kuivinen
Message 2 of 13 in “Add git-annotate, a tool for assigning blame.”
  1. Add git-annotate, a tool for assigning blame.Ryan Anderson, Feb 20, 2006
  2. Junio C HamanoFeb 20, 2006
  3. Fredrik KuivinenFeb 20, 2006
  4. Junio C HamanoFeb 21, 2006
  5. Fredrik KuivinenFeb 28, 2006
  6. Junio C HamanoFeb 28, 2006
  7. Ryan AndersonFeb 28, 2006
  8. Andreas EricssonFeb 28, 2006
  9. Ryan AndersonFeb 23, 2006
  10. Fredrik KuivinenFeb 23, 2006
  11. Johannes SchindelinFeb 24, 2006
  12. Junio C HamanoFeb 24, 2006
  13. Johannes SchindelinFeb 24, 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.