A useful non-Perl offering from the Googles: <a href="http://code.google.com/p/google-diff-match-patch/">http://code.google.com/p/google-diff-match-patch/</a><div><br></div><div>• diff with efficiency (diff by block(?), word, or character)</div>

<div>• fuzzy matching</div><div>• patching</div><div><br></div><div>Caveat: not Perl.</div><div><br><div class="gmail_quote">On Thu, Apr 14, 2011 at 11:06 PM, Aristotle Pagaltzis <span dir="ltr"><<a href="mailto:pagaltzis@gmx.de">pagaltzis@gmx.de</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">* Matthew Wickline <<a href="mailto:m_pm_pdx@wickline.org">m_pm_pdx@wickline.org</a>> [2011-04-14 07:35]:<br>
<div class="im">> I've added some examples. If you diff -u the before and after<br>
> files you should get something like the png at<br>
><br>
>    <a href="https://github.com/wickline/diff_painter/blob/master/examples/painted_diff.png" target="_blank">https://github.com/wickline/diff_painter/blob/master/examples/painted_diff.png</a><br>
><br>
> Note that the bottom two block edits didn't render as block<br>
> edits because a rows was added or inserted. The script does not<br>
> try to merge lines when presented with N minus lines followed<br>
> by other-than-N plus lines. It only wants to merge N minus<br>
> lines with N plus lines.<br>
<br>
</div>Ahh. I see. That was the case I was hitting at least in several<br>
of the cases it seemed to not be doing anything.<br>
<br>
It finally worked fine on other diffs since, so it *is* working.<br>
<div class="im"><br>
> Another case you might be hitting is that if too many edits are<br>
> done in a line, it decides that it would look better to show<br>
> you "this whole line changed into this other whole line" rather<br>
> than trying to merge the two lines.<br>
<br>
</div>No. But there was one case where I had a single-line change where<br>
into which I had inserted a short substring, that diff_painter<br>
was not rendering as I expected, even though it seemed that it<br>
should be able to. Unfortunately I didn’t write down the commit<br>
in question so I can’t re-check now.<br>
<br>
Was this possibly because `git diff` merged the one-line change<br>
into a single diff hunk together with another change where one<br>
line was split into three?<br>
<br>
In that case it means diff_painter would be able to sprinkle its<br>
magic on more of the diff if the context is reduced (`-U0` in the<br>
extreme) – right?<br>
<br>
If so then it would be better to split the diff hunks on its own<br>
(ie collect +/- stretches between unchanged lines) instead of<br>
only relying on the numbers in the hunk head, and then operate<br>
on these sub-hunks. (Otherwise it’s useless for complex changes<br>
best read using `-U999` to get a before/after of the whole file,<br>
where it could do the most to help the reader.)<br>
<div class="im"><br>
> As for input, basically anything that looks like diff or diff<br>
> -u. That would include svn diff and git diff and git log -p.<br>
<br>
</div>Right, yes.<br>
<div class="im"><br>
--<br>
Aristotle Pagaltzis // <<a href="http://plasmasturm.org/" target="_blank">http://plasmasturm.org/</a>><br>
_______________________________________________<br>
</div><div><div></div><div class="h5">Pdx-pm-list mailing list<br>
<a href="mailto:Pdx-pm-list@pm.org">Pdx-pm-list@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/pdx-pm-list" target="_blank">http://mail.pm.org/mailman/listinfo/pdx-pm-list</a></div></div></blockquote></div><br></div>