Over a million developers have joined DZone.

Source Control Merges by Trimming Trailing Whitespace Made Easy

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

If you do frequent branch merges in any source control system, you have likely encountered merge conflicts. When two branches have legitimate differences, most often you have to resolve those differences by hand. But all too often, when resolving diffs, you end up looking at a lot of "phantom diffs", too. The most common phantom diff is the trailing whitespace difference.


Just like standardization of space/tab between developers, deciding as a team to not commit changes with trailing whitespace can make your merging easier. You could to this with a git hook, or you could just configure your editor to do it.

In Eclipse, this requires a plug-in called AnyEdit. Once the plug-in is installed, enabled this option is under Preferences -> General -> Editors -> AnyEdit Tools.


But what about all the code you already have? Ideally you would get all the developers on a unified branch, perhaps after a sprint ends, and update the whole codebase at once to remove trailing spaces. In Linux, you run the following from the root of your code directory. Note the extension list in the first part.

echo "*.py,*.js,*.css,*.html" |xargs -d, -I ext find . -type f -name ext -print0 |xargs -0 sed -i .bak -e "s/[[:space:]]*$//"



Source: http://bitkickers.blogspot.com/2011/08/easier-source-control-merges-by.html

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}