I am looking for ways to optimize blame while using jgit (if its possible at all).
When using git, this will give results for lines 40-60.
git blame -L 40,60 foo
I could use something like this to limit computing blame results:
BlameGenerator bg = new BlameGenerator(git.getRepository(), "foo");
bg.prepareHead();
BlameResult br = BlameResult.create(bg);
br.computeRange(40, 60);
The computeRange method seems to compute blame (BlameGenerator#next) until it reaches a blame section which ends after our range. However, this means it still calculates blame results from the beginning of the file, until it reaches that section.
Assuming blame can be an expensive operation for files with long history, is there another, more optimal way to do this? What I'm thinking of, is a way to only compute blame for the sections which encompass the line range we want.
I'm not too familiar with git objects, so not sure if it's straightforward to extend BlameGenerator/BlameResult to do this.