Community
Participate
Working Groups
When I try to execute pull with following code: git.pull() .setStrategy(MergeStrategy.THEIRS) .setRebase(true) .call().isSuccessful(); I got following error: java.lang.ClassCastException: org.eclipse.jgit.merge.StrategyOneSided$OneSide cannot be cast to org.eclipse.jgit.merge.ResolveMerger at org.eclipse.jgit.api.CherryPickCommand.call(CherryPickCommand.java:152) ~[org.eclipse.jgit-4.4.1.201607150455-r.jar:4.4.1.201607150455-r] at org.eclipse.jgit.api.RebaseCommand.cherryPickCommitFlattening(RebaseCommand.java:527) ~[org.eclipse.jgit-4.4.1.201607150455-r.jar:4.4.1.201607150455-r] at org.eclipse.jgit.api.RebaseCommand.cherryPickCommit(RebaseCommand.java:503) ~[org.eclipse.jgit-4.4.1.201607150455-r.jar:4.4.1.201607150455-r] at org.eclipse.jgit.api.RebaseCommand.processStep(RebaseCommand.java:454) ~[org.eclipse.jgit-4.4.1.201607150455-r.jar:4.4.1.201607150455-r] at org.eclipse.jgit.api.RebaseCommand.call(RebaseCommand.java:368) ~[org.eclipse.jgit-4.4.1.201607150455-r.jar:4.4.1.201607150455-r] at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:324) ~[org.eclipse.jgit-4.4.1.201607150455-r.jar:4.4.1.201607150455-r]
That looks like a severe bug. I'll have a look
I attach my small standalone program which reproduces this bug. I also have a fix prepared but I am not sure exactly what you want. If you look at [1] you see the term "ours" is used twice. Once as a merge strategy and once as an option to the recursive merge strategy. Which one do you want. E.g. if you have branch master and branch side and on side a brand new file "new.txt" was created. If you are sitting on master do "git merge side" .... do you want that the file "new.txt" exists afterwards or not. [1] https://git-scm.com/docs/merge-strategies
Created attachment 264072 [details] a standalone java program showing the bug
The same issue for StashApplyCommand. As I see in the code, the merger is casted to ResolveMerger - https://github.com/eclipse/jgit/blob/ad1548b49ee3954814f95d14e111d5e70c811186/org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java#L195: ResolveMerger merger = (ResolveMerger) strategy.newMerger(repo); However, in case of the OURS/THEIRS MergeStrategy, the merger is of type org.eclipse.jgit.merge.StrategyOneSided.OneSide.
While there is a fix being issued, is there a recommended workaround?
Any chances this can be fixed soon? This bug has been around for 5 years and hasn't been fixed yet. It's unfortunate that JGit is the only java git library available out there and it has so many bugs, especially related to rebase.
Same issue for RebaseCommand. Any progress on this issue? Or does anybody have a workaround?
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/179234
Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/179234 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=8210f29fe43ccd35e7d2ed3ed45a84a75b2717c4