Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » JGit(Rename/Copy detection using FollowFilter)
JGit [message #1118463] Fri, 27 September 2013 12:38
Ajay Gour is currently offline Ajay GourFriend
Messages: 5
Registered: September 2013
Junior Member
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 problem with this code - 1. Though it 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?

2. I have cloned wildfly (github"dot"com"slash"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 ran -

git log --follow --name-status -- build/src/main/resources/modules/org/jboss/as/clustering/common/main/module.xml

command, it gives following result

commit 659621a4ccfa9b45416537aebb14cda0419bb82d
commit b1d3bf705461754307237dd9ca2a2211f3ef4022
commit c1d1a77fd4beb956c1a353c02da972c58f5a3643
commit d218ab3cdd086501d5d4bf585971b9358d303a60
commit 601ecd1a4c8dfc4d2ad63e91b212abf36a049e74
commit 0f15dc8a1330ee24816ac7f64d63afb0cd1ee725
commit f4bfb891a9da0f052235299ad33d43bdf9ec7493
...

However, 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?

Thanks for any help in advance,
- Ajay

(BTW, that Java code gives correct result for our repository which we migrated from SVN to GIT.)

Previous Topic:JGit - How to specify commit message for merge commit?
Next Topic:head not master in decorator text
Goto Forum:
  


Current Time: Thu Dec 18 23:09:30 GMT 2014

Powered by FUDForum. Page generated in 0.02764 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software