Sunday, November 17, 2013

The Perils of Auto-Merge and the Advent of Semantic Merge

Just because a VCS tool can auto-merge, that doesn't mean there isn't one!

What can be auto-merged by a tool unaware of the programming language?
  • add file
  • delete file
  • rename file: http://stackoverflow.com/questions/2701790/git-merge-with-renamed-files
  • change parts of a file which don't overlap with other changes
Trivial examples of how these auto-merges can break the app:

add
  • The new Jasmine spec has an error.
  • A new configuration file overrides the default configuration in a dysfunctional way.
delete
  • The main module is gone so the app won't run.
  • A CSS file is gone so the pages aren't styled.
rename
  • require("Counter") fails because Counter.js is now TheCounter.js.
"no-conflict" changes
function square(x) {
- return x * x; #
+ return x * x * x;
}
A careful engineer reviews all changes (his changes & others') to increase the chance of a problem-free merge:
git diff <branch> <branch>
git diff master rough

Unfortunately:
git mergetool
only shows conflicts.

Unit tests provide an additional check.

Now, there's a "semantic" merge tool which understands the programming language:




No comments:

Post a Comment