structure merge in git

I'm a software developer working in a team, so I inevitably have to deal with merging code. Fortunately in most cases the automatic merger can do without my help, and only occasionally I have to resolve conflicting changes. Also it is usually just moving some lines around and fixing punctuation. However I was quite impressed by the article "How to merge json files using git": it had two concepts which were new to me. One was moderately interesting, about extensive configuration for merging in git. Another one was much bigger. I has never occured to me that the automatic merger can be smart enough to understand the structure of the code it is merging (as opposed to dumb checking of line numbers). The article only talks about JSON but we can go further! How about smart merger for Javascript?

So I headed out on a search for such tools to plug them into my git. And I was quite impressed by the landscape. Long story short, the problem can be described as the comparison of two Abstract Syntax Trees, and it was shown to have a complexity of O(n*n). Quite complex! And the applied process is usually called structural merge or semantic merge. There are tools trying to do that but they cost a lot to compensate for the complexity of implementation. Though Eclipse has something like that too, but I haven't tried it.

Having looked at this I realised that my problem is too rare and too small to pay so much for it, and too complex to roll my own. But here are some links in case you want to check them out:

Artemy Tregubenko,

comments powered by Disqus