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

[JGIT] Blame functionality for jgit

From
MWManuel Woelker <manuel.woelker@gmail.com>
Date
Jan 11, 2009, 20:23 UTC
Message-ID
<3d045c7e0901111223j43a69402s28a59612212943f3@mail.gmail.com>
Hello there,

Over the weekend I have been hacking the jgit sources a little to see if I can add blame/praise/annotate functionality to it. The results can be found at http://github.com/manuel-woelker/egit/tree/blame . All work is in the blame branch in org.spearce.jgit.blame package.

I largely ported the cgit blame algorithm described here https://kerneltrap.org/mailarchive/git/2006/10/12/224187 , the relevant file is builtin-blame.c cf. http://repo.or.cz/w/git.git?a=blob;f=builtin-blame.c;hb=HEAD

The structure has been kept largely intact, but I have tried to translate the concepts to idiomatic java, with the bulk of the logic now in the Scoreboard class

The blame algorithm needs to use a diff algorithm to find common parts in files. AFAICT there is no diff implementation in jgit at the moment. I used the incava java-diff library, (see http://www.incava.org/projects/java/java-diff ), but I introduced an interface that should make it possible to swap implementations with a minimum of effort. To compile I just create a new eclipse project with the java-diff sources.

Currently renames, copies etc. are not supported, so only files with the same name can receive the blame. Unmodified renames and copies should be fairly simple to implement. Modified renames and copies might prove to be a little bit harder, so that would have to wait until jgit can follow history across renames/copies.

There are some simple unit tests to check the basic functionality. I also "blamed" SUBMITTING_PATCHES in the egit repo, and got the same results as cgit. I am certain that there a some bugs lurking in the code, but overall it looks quite promising.

I would like to hear your thoughts on a couple of topics:
 - Merge/patch/diff/blame functionality needs a diff implementation,
what are our options within technical and license constraints?
 - What is the roadmap for these features?
 - Can you see this blame effort getting integrated upstream?

I would love to contribute more effort to egit and the blame functionality in particular. To me, "blame" is one of the killer features of modern SCMs.

Last no least, kudos to the git and egit teams for their hard work on
making git such a great piece of software.
 - Manuel Woelker
Next: Shawn O. Pearce
Message 1 of 4 in “[JGIT] Blame functionality for jgit”
  1. Manuel WoelkerJan 11, 2009
  2. Shawn O. PearceJan 12, 2009
  3. Manuel WoelkerJan 12, 2009
  4. Shawn O. PearceJan 12, 2009

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.