# Merge / Diff algo

**URL:** <https://www.ruby-forum.com/t/merge-diff-algo/88965>\
**Category:** Ruby\
**Created:** [March 15, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/merge-diff-algo/88965 "2007-03-15T23:10:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [March 15, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/merge-diff-algo/88965/1 "2007-03-15T23:10:49Z")

</div>

Is there any lib to do simple text based merges (3 way) from Ruby?

Perhaps it’s simple enough to do without an external lib. Just need  
to see which lines child1 added to parent, which ones child1 deleted,  
and same for child2, and then merge them - in order…

Hmmm… perhaps I should use an external lib…

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [March 15, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/merge-diff-algo/88965/2 "2007-03-15T23:56:55Z")

</div>

On Fri, 16 Mar 2007, S. Robert J. wrote:

> Is there any lib to do simple text based merges (3 way) from Ruby?
> 
> Perhaps it’s simple enough to do without an external lib. Just need  
> to see which lines child1 added to parent, which ones child1 deleted,  
> and same for child2, and then merge them - in order…
> 
> Hmmm… perhaps I should use an external lib…

`diff3 -Em myfile oldfile yourfile`

John C. Phone : (64)(3) 358 6639  
Tait Electronics Fax : (64)(3) 359 4632  
PO Box 1645 Christchurch Email : removed\_email\_address@domain.invalid  
New Zealand

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [March 16, 2007, 1:59am UTC](https://www.ruby-forum.com/t/merge-diff-algo/88965/3 "2007-03-16T01:59:07Z")

</div>

On 3/15/07, S. Robert J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there any lib to do simple text based merges (3 way) from Ruby?
> 
> Perhaps it’s simple enough to do without an external lib. Just need  
> to see which lines child1 added to parent, which ones child1 deleted,  
> and same for child2, and then merge them - in order…
> 
> Hmmm… perhaps I should use an external lib…

I seem to recall that someone had put some merge operations around  
Diff::LCS.

-austin
