tags:

views:

62

answers:

2

Our project is working within fairly close quarters code-wise (a lot of changes happening in parallel in a fairly small geographical area of the code), and our feature branch based git workflow works out really nice for our java code.

But the xml/html stuff is not working really well. Simple unrelated changes (a designer adding a surrounding div, a developer changing an id of an element within) gives really disasterous merges.

I realize there may be several options on how to handle this. A good git xml merge would be optimal, or putting restrictions on reformatting of xml/html code another. Not working in such close quarters would be another (unacceptable) option.

How do you solve this problem efficiently ?

+1  A: 

If you know you could automate some of the merge issue you are having with those merges of xml files, you could script those resolutions.
If there is script, you can call them from a merge driver tailored for xml/xhtml files, only in some directories.

See here for a (really simple) of a merge driver.

That way, any conflict which remains (because the merge driver script did not solve it) are legitimate merge issues that need to be addressed.

VonC
+1  A: 

Git allows for custom merge drivers, selected via gitattributes per path (e.g. for all *.xml files).

What you need to find is a XML-aware merge driver, plus possibly also write a simple script to transform between Git conventions and said merge driver conventions. There is for example XML::Merge Perl module. There is XyDiff, but it looks like it lacks three-way merge (and I guess that for XML building 3-way merge from diffs like described in A Formal Investigation of Diff3 paper (PDF) wouldn't work). You can also read Matching, diffing and merging XML blog post (or article referenced therein).

Another solution would be to unset merge attribute for XML files (they would be treated like binary files wrt. merge conflicts), and use some graphical merge tool to resolve merge conflicts, perhaps via git mergetool.

Jakub Narębski
I'm somehow thinking that a merge that simply ignores all kinds of leading/trailing whitespace (except linebreaks) would perform well enough. Do you know how I can achieve this ?
krosenvold