Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle xml/html in git feature branch workflow?

Tags:

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 ?

like image 581
krosenvold Avatar asked Nov 05 '09 16:11

krosenvold


People also ask

Can git merge XML files?

It's possible to integrate our XML and JSON aware merge products into the Git merge process as either a merge driver or merge tool.

Which one is the best branching Git workflow to follow?

Git Flow. The Git Flow is the most known workflow on this list. It was created by Vincent Driessen in 2010 and it is based in two main branches with infinite lifetime: master — this branch contains production code.


2 Answers

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.

like image 115
Jakub Narębski Avatar answered Sep 29 '22 09:09

Jakub Narębski


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.

like image 20
VonC Avatar answered Sep 29 '22 09:09

VonC