Automatic Code Formatting and Merges

…or, how to give other developers screaming nightmares in 10 seconds flat.

The next time you think to reach for the “reformat source code” button in your IDE, think twice before you press it. Automatic reformatting is a great way to turn a small merge hazard contained to a single method into a huge merge hazard affecting an entire file. Merge tools are relatively stupid: in general, they’re not aware of the syntactic structure of a source file, just the text by lines; as a result, it’s very easy to fool them into thinking a one-line change and a reformat are a conflict covering the entire file.

If you’re using automatic formatting tools, please check with the other developers on your project and make sure that your code formatter settings agree with theirs. If you can’t make that happen, then don’t reformat code unless everyone’s nobody but you is touching those files.

Please, think of the merges.

1 Comment

  • By Kit, January 10, 2009 @ 6:45 pm

    I’ve come across this like burning with shared python files and a group that disagreed on tab v. spaces. Also, on a shared TeX document, where people had differing attitudes towards linebreaks in the middle of paragraphs.

Other Links to this Post

RSS feed for comments on this post. TrackBack URI

Leave a comment

Image | WordPress Themes