is gnucash files patch/diff friendly?

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Mon Jun 15 11:18:29 EDT 2009


On Mon, Jun 15, 2009 at 09:43:08PM +0800, Zhang Weiwu wrote:
> Hello. We are using gnucash files without compression. I am wondering if
> gnucash files are patch/diff friendly, because we often share other
> files (for other projects) using unison, a file synchronization tool,
> that merges changes from two modified version using traditional
> diff/patch unix commands.
> 
> Say, if person A recorded a transaction, person B recorded a different
> transaction, both kept the last unmodified version, can they merge their
> changes with traditional unix diff/patch?
> 
> Some text formats are patch/diff friendly and some are not. I can
> imagine, e.g. if gnucash keeps account sum in file, then it is not
> patch/diff-friendly, because two transactions both changed sum,
> resulting a conflict.
> 
> I mostly believe gnucash must not be patch/diff friendly because it may
> result inefficient loading & saving, unless an index is maintained
> outside of the main transaction record and gets updated when finding
> index & transaction modification date different. But I ask anyway, just
> in case.

gnucash files are XML files.  XML files contain brackets that have to 
match over long distances.  The usual diff3 mechanism for merging works 
on a line-by-line basis without taking any notice of the bracket 
structure.  It is therefore possible for the brackets to become 
mismatched after a merge.  This would require hand-editing.  It's 
possible to have recombinant transactions, which seem valid, but are 
wrong.

What's more, gnucash files contain an actual count somewhere of the 
number of accounts, tbe number of transactions, and so forth.  Even if 
marge manages to merge the XML files and come up with valid XML, it is 
quite unlikely to get the counts right.

-- hendrik


More information about the gnucash-user mailing list