How does the Resolve simple conflicts work in Intellij IDEA
Answered
In fact, I've tried to ask this question on Stackoverflow, but for some reason got the question closed.
Simply, I would like to know how it works. What does IJ Idea consider a simple conflict? Is it safe to use it?
Please sign in to leave a comment.
The logic is pretty simple, the same as git uses when auto-resolving. Git, however, operates with lines, and Resolve simple conflicts operates with words in the line.
So It compares a line from left and right on a by-word basis. If a word is changed only on one side, the change is applied to the result. If the word is changed on both sides - then it is not a simple conflict.
Let's illustrate with the example mentioned in the doc - if the beginning and the end of the same line have been modified in different file revisions.
The base revision: This is a simple conflict that can be resolved.
Revision 1: Below is a simple conflict that can be resolved.
Revision 2: This is a simple conflict that can be resolved automatically.
The difference between Revision 1 and base is the beginning - This change to Below. This part is not changed in revision 2.
The difference between Revision 2 and the base is the last word - automatically, which is not changed in revision 1.
So this can be merged into Below is a simple conflict that can be resolved automatically.
Hope this simple example explains the behavior.
Here is the article regarding that: https://www.jetbrains.com/help/idea/resolve-conflicts.html
Do you want to know something more exact?
> What I'm wondering is: is there an equivalent
git
command, or is this something that the IDE is doing with its own logic?This is a feature of IDE. To the best of my knowledge, git does not have an equivalent. Diff-algorithm has a limited number of options and they affect how git operates lines.
Thanks, Kostya for the quick reply. But could you please give more explanation for the following excerpt that I took from the link you provided: "if the beginning and the end of the same line have been modified in different file revisions"
I'd appreciate it if you explained it by giving an example.
Thank you, Dima, a lot. I wouldn't imagine that would be such a simple logic. Now it's all set.
I'd also like to understand this better.
@... your explanation is very clear, thank you.
What I'm wondering is: is there an equivalent
git
command, or is this something that the IDE is doing with its own logic?Eg, is it passing something to
git merge diff-algorithm=
?Hi Tim,
IDE communicates with your git exe and passes commands there. Once you perform some VCS commands a console tab in your Git window will appear and you may see which commands are sent.
Thanks! Its brilliant, and will keep using it :)