Sometimes when I do the following:
BlameCommand blamer = new BlameCommand(repo);
ObjectId commitID = repo.resolve("head");
blamer.setStartCommit("head");
blamer.setFilePath(fileName);
BlameResult blame = blamer.call();
RevCommit commit = blame.getSourceCommit(0); //set to first line but can be random line of file
The commit obtained from the last line in the sample code is null
; it is not always null
, just on some lines of some files. I suspected it has to do with CR/LF issues as I am running this code on a windows machine so I tried changing both my global and repository config core.autocrlf
values. I tried both true and false for core.autocrlf but I still have the same problem.
Currently using: jgit-3.1.0.201310021548
I added a snippet at the jgit-cookbook that uses the BlameCommand, it works fine there, in your sample code the setStartCommit() is wrong, it should be the commitID.
The following works for me:
BlameCommand blamer = new BlameCommand(repository);
ObjectId commitID = repository.resolve("HEAD");
blamer.setStartCommit(commitID);
blamer.setFilePath("README.md");
BlameResult blame = blamer.call();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.