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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 24, 2006, 00:00 UTC
Message-ID
<Pine.LNX.4.63.0602240055080.31816@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<20060223225547.GB8673@c165.ib.student.liu.se>
Hi,
On Thu, 23 Feb 2006, Fredrik Kuivinen wrote:
Show 13 quoted lines
> On Thu, Feb 23, 2006 at 05:10:49PM -0500, Ryan Anderson wrote:
> > (Biased critique since I have the other tool in the tree, but still...)
> > 
> > > +    FILE* fout = fopen("/tmp/git-blame-tmp1", "w");
> > 
> > Probably should be using something like mkstemp (mkstmp?) here, so if
> > someone is runnign things as root or with a malicous user around, things
> > don't collide.
> > 
> > Hell, so on a multi-user machine this doesn't blow up on you.
> 
> Yep, I know. The code is mostly a proof of concept. I didn't submit it
> for inclusion.
Ha ha, famous last words!
Show 33 quoted lines
> > But, read down for a related comment.
> > 
> > > +    if(!fout)
> > > +        die("fopen tmp1 failed: %s", strerror(errno));
> > > +
> > > +    if(fwrite(info_c->buf, info_c->size, 1, fout) != 1)
> > > +        die("fwrite 1 failed: %s", strerror(errno));
> > > +    fclose(fout);
> > > +
> > > +    fout = fopen("/tmp/git-blame-tmp2", "w");
> > > +    if(!fout)
> > > +        die("fopen tmp2 failed: %s", strerror(errno));
> > > +
> > > +    if(fwrite(info_o->buf, info_o->size, 1, fout) != 1)
> > > +        die("fwrite 2 failed: %s", strerror(errno));
> > > +    fclose(fout);
> > > +
> > > +    FILE* fin = popen("diff -u0 /tmp/git-blame-tmp1 /tmp/git-blame-tmp2", "r");
> > > +    if(!fin)
> > > +        die("popen failed: %s", strerror(errno));
> > 
> > Can't git-diff-tree do this sufficiently, anyway?  See my Perl script
> > for an example, you just need both commit IDs and both filenames and the
> > appropriate -M and you get the right results.
> > 
> > (It's possible that's part of where the performance differences are,
> > though, not really sure at the moment.)
> > 
> 
> Yeah.. maybe. My first thought was to avoid forking and execing diff
> and use some C library for doing the diffing instead (libxdiff). But
> then I just wanted to get some code working and the simplest solution
> I could think of was to fork and exec diff.

git-diff-tree fork()s a diff. So, by fork()ing git-diff-tree you get two fork()s (and no knife...).

Show 8 quoted lines
> > I'm going to stop there for the moment, I'm not really confident in my
> > understanding of git-internals to say much more just yet.
> > 
> > This could probably benefit a *LOT* from the libification project, I
> > think, though.
> 
> Yes, perhaps. Some of the git-rev-list bits might simplify a couple of
> things.

The major problem is probably not solved: What Linus calls a "stream interface".

I.e. if you pipe the output of git-rev-list to another program, you *need* to execute the two semi-simultaneously. The "alternative" would be to use buffers, which can get huge (and are sometimes not needed: think git-whatchanged, which starts outputting before it's getting no more input).

> I have found some severe problems with the code I posted, in
> particular it doesn't handle parallel development tracks at all. I am
> working on fixing it, but it isn't finished yet.
Looking forward to them!

Ciao, Dscho

Previous: Fredrik KuivinenNext: Junio C Hamano
Message 11 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.