A Formal Investigation of Diff3

  • Sanjeev Khanna
  • Keshav Kunal
  • Benjamin C. Pierce
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4855)


The diff3 algorithm is widely considered the gold standard for merging uncoordinated changes to list-structured data such as text files. Surprisingly, its fundamental properties have never been studied in depth.

We offer a simple, abstract presentation of the diff3 algorithm and investigate its behavior. Despite abundant anecdotal evidence that people find diff3’s behavior intuitive and predictable in practice, characterizing its good properties turns out to be rather delicate: a number of seemingly natural intuitions are incorrect in general. Our main result is a careful analysis of the intuition that edits to “well-separated” regions of the same document are guaranteed never to conflict.


Formal Investigation Maximum Match Synchronization Algorithm Longe Common Subsequence Approximate String Match 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Smith, R.: GNU diff3, Version 2.8.1, April 2002; distributed with GNU diffutils package (1988)Google Scholar
  2. 2.
    Lindholm, T.: A three-way merge for xml documents. In: DocEng 2004: Proceedings of the 2004 ACM symposium on Document engineering, pp. 1–10. ACM Press, New York (2004)CrossRefGoogle Scholar
  3. 3.
    Chawathe, S.S., Rajamaran, A., Garcia-Molina, H., Widom, J.: Change detection in hierarchically structured information. ACM SIGMOD Record 25(2), 493–504 (1996)CrossRefGoogle Scholar
  4. 4.
    Lanham, M., Kang, A., Hammer, J., Helal, A., Wilson, J.: Format-independent change detection and propagation in support of mobile computing. In: Brazilian Symposium on Databases (SBBD), Gramado, Brazil, pp. 27–41 (October 2002)Google Scholar
  5. 5.
    MacKenzie, D., Eggert, P., Stallman, R.: Comparing and Merging Files with GNU diff and patch. Network Theory Ltd. Printed version of GNU manual (2003)Google Scholar
  6. 6.
    Miller, W., Myers, E.W.: A file comparison program. Softw., Pract. Exper. 15(11), 1025–1040 (1985)CrossRefGoogle Scholar
  7. 7.
    Myers, E.W.: An o(nd) difference algorithm and its variations. Algorithmica 1(2), 251–266 (1986)MathSciNetzbMATHCrossRefGoogle Scholar
  8. 8.
    Ukkonen, E.: Algorithms for approximate string matching. Information and Control 64(1-3), 100–118 (1985)MathSciNetzbMATHCrossRefGoogle Scholar
  9. 9.
    Foster, J.N., Greenwald, M.B., Kirkegaard, C., Pierce, B.C., Schmitt, A.: Exploiting schemas in data synchronization. Journal of Computer and System Sciences (2007) To appear. Extended abstract in Database Programming Languages (DBPL) (2005)Google Scholar
  10. 10.
    Mens, T.: A state-of-the-art survey on software merging. IEEE Trans. Software Eng. 28(5), 449–462 (2002)CrossRefGoogle Scholar
  11. 11.
    Stallman, R., et al.: Comparing and merging files, Manual for GNU diffutils (2002), available at

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Sanjeev Khanna
    • 1
  • Keshav Kunal
    • 2
  • Benjamin C. Pierce
    • 1
  1. 1.University of PennsylvaniaUSA
  2. 2.YahooUSA

Personalised recommendations