Bug 519832 - git merge tool fails
Summary: git merge tool fails
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-18 10:40 EDT by Jonathan Locke CLA
Modified: 2017-08-30 03:15 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Locke CLA 2017-07-18 10:40:40 EDT
I did a merge with built-in git support in Neon and I get poor results quite often. Two files with methods that are repeated like:

    public XYZ newXYZ() {
        return XYZ.newInstance(5);
    }

    public XYZ newXYZ() {
        return XYZ.newInstance(5);
    }
    
This shouldn't be possible in a merge of two Java files that both compile, and yet somehow it didn't match these up correctly. Unfortunately, I can't post our source code for legal reasons, but there are many, many examples of this in any big merge (a few hundred files).
 
I honestly don't think it's worth working on the old diff tools for merging. Instead it would be better if there was a new Java-aware merge tool for git that used the structure of the code to merge things. Moving a method, changing spacing or comment wrapping or other unimportant differences shouldn't be flagged as complicated conflicts. Instead the diff tool should look at class members and see what changed in terms of members and then only diff the code inside each method with the corresponding method in the other file. Right now, methods can be split when diffing in really ugly and weird ways that make it very hard to do merges. I think a smart merger for Java could really make everyone's life a LOT easier and it would be a unique Eclipse advantage. Although I'm too swamped to work on such a thing, I don't think this is as hard as it sounds. If both files compile, it should be possible to compare the members for +/-/~ and to use the existing diff code inside each method.

Thanks for listening.

     Jon

-- Configuration Details --
Product: Eclipse 4.6.3.20170314-1500 (org.eclipse.epp.package.java.product)Installed Features:
 org.eclipse.jdt 3.12.3.v20170301-0400
Versioning Plugin:
 org.eclipse.platform 4.6.3.v20170301-0400
Comment 1 Matthias Sohn CLA 2017-08-30 03:15:20 EDT
I agree this would improve merging for Java sources, though there are many other languages and we need someone who has time to work on a language specific merge algorithm