On Wednesday 29 September 2010 18:45:29 Jean Delvare wrote:
> Hi there,
> 
> I have attached two versions of a C source GNU diff has a hard time
> diff'ing. The only difference between the two files is that several
> functions have been moved around to avoid forward declarations. But the
> output of "diff -u" is more complex than it should be. While I can
> understand that the algorithm is not perfect and can lead to results
> different from what a human would have done, the following excerpt:
> 
> -     if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
> -             return -ENODEV;
> +     if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
> +             return -ENODEV;
> 
> is obviously wrong, no matter how you look at it.
>
> "diff -ud" gets the correct output.

But doesn't this already answer your question?  Diff doesn't find the minimal 
diff when using the fast algorithm which doesn't guarantee optimal results.

> Apparently git does as well (I originally received the difference between
> the two files as a git patch.)

Git 1.7.3.rc2 produces the same, non-minimal result as GNU diff 2.8.7-cvs 
without the -d option for me.

Andreas

Reply via email to