So what i am trying to do is to detect rename/copy activities on a source code file since it is added to the repository. I am using following code -
/**
*
* @param path source code file to retrieve complete history
* @param start latest commit made for "path" to mark as start (tested with HEAD also)
* @return
*/
private RevCommitList<RevCommit> getList(String path, RevCommit start) throws Exception {
Config config = new Config(git.getRepository().getConfig());
config.setString("diff", null, "renames", "copies");
config.setInt("diff", null, "renameLimit", Integer.MAX_VALUE);
DiffConfig diffConfig = config.get(DiffConfig.KEY);
final RevWalk revWalk = new RevWalk(git.getRepository());
//revWalk.reset();
revWalk.setTreeFilter(FollowFilter.create(path, diffConfig));
revWalk.markStart(revWalk.parseCommit(start));
final RevCommitList<RevCommit> list = new RevCommitList<RevCommit>();
list.source(revWalk);
list.fillTo(Integer.MAX_VALUE);
return list;
}
There are 2 problems with this code -
Though JGit is able to detect "RENAMES" it is failing to detect "COPY" activities. Wherever any Copy activity is encountered, it just stops and doesn't fetch further activities. Can someone please help in identifying what could possibly be wrong with the code?
I have cloned wildfly (https://www.github.com/wildfly) repository for my testing. I am retrieving file history using git's command line tool and using above mentioned code to make sure that both are giving same results atleast until "Copy" activity. But there seems to be considerable difference in the results given by git's command line tool and above mentioned code. E.g. When i run
git log
command -git log --follow --name-status -- build/src/main/resources/modules/org/jboss/as/clustering/common/main/module.xml
it gives following result
- 659621a4ccfa9b45416537aebb14cda0419bb82d
- b1d3bf705461754307237dd9ca2a2211f3ef4022
c1d1a77fd4beb956c1a353c02da972c58f5a3643
d218ab3cdd086501d5d4bf585971b9358d303a60
- 601ecd1a4c8dfc4d2ad63e91b212abf36a049e74
- 0f15dc8a1330ee24816ac7f64d63afb0cd1ee725
- f4bfb891a9da0f052235299ad33d43bdf9ec7493
...
but my Java code is giving following results -
- 659621a4ccfa9b45416537aebb14cda0419bb82d
- b1d3bf705461754307237dd9ca2a2211f3ef4022
c1d1a77fd4beb956c1a353c02da972c58f5a3643
67dce2a276a410805b064e962b6950c6d07cf436
- 60537d19617a81e9505240f1dc5ad0567978fd96
- 4f1dff9ee4d79487d898c4917ca9bc3d842dc6cf
- 53cd538018a2bf57998c65202d27d6423a6f02f3
As you can see from 4th commit onwards all commit names are wrong. Any idea what could possibly be wrong?
(BTW, that Java code gives correct result for our repository which we migrated from SVN to GIT.)