Conference Paper

Merge and Graft: Two Twins That Need to Grow Apart

Software developers are familiar with merge, e.g., pulling together changes from one branch into another in a version control system. Graft is a more selective process, pulling changes from selected commits onto another branch. These two processes are often implemented in the same way, but there are important differences between the two that needs addressing.

Git and Mercurial have different ways to determine the correct ancestor when performing a merge operation. Graft operations use yet another way to determine the ancestor. In the built-in line-based algorithm, the underlying diff3 process is then used. This diff3 algorithm accepts non-conflicting changes and relies on the user to resolve conflicts. We will examine the details of this process and suggest that the symmetrical treatment that diff3 uses is appropriate for merge but not necessarily optimal for the graft operation.

In this paper we look at examples of tree-based structures such as XML and JSON to show how different approaches are appropriate for merge and graft.

Download this conference paper to:

  • Understand the fundamental differences between merge and graft.
  • Understand how results can differ when finding change depending on the method you’re using.
  • Review the advantages of XML for rule-based conflict resolution.

Gated

“Merge tools are, usually, line-based tools that treat the files as a sequence of lines but they have no understanding of any syntactic structure that may be present.”

Related Media

Industry Use Case

DeltaXignia and Developers and Data Specialists

XML Merge is a complete toolkit for reliably merging 3 or more XML documents or datasets into a single file. Download the product sheet to understand how the solution helps to identify all the meaningful diffs between your XML files.

Conference Paper

An improved diff3 format for changes and conflicts in tree structures

Diff3 works surprisingly well for pretty-printed source code and similar documents. But it has frustrating limitations when used for XML or JSON or similar tree-based data formats. Can it be improved?

Product Discussion

Understanding Two and Three Way Merge

It’s common to have data in two files that we need to merge together, two different people or two different processes have made changes. Does it matter who or what has made this change? This question might help to decide whether you need a 2-way or 3-way merge.

© 2000-2025 DeltaXML Ltd. registered in England and Wales (Company No. 2528681), trading as DeltaXignia. All rights reserved