# git reveals a bug in (some versions) BSD diff

4 messages from 2005-08-12 to 2005-08-12. Participants: Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/1481

## Johannes Schindelin, 2005-08-12 12:32

Subject: git reveals a bug in (some versions) BSD diff
Message-ID: <Pine.LNX.4.63.0508121424500.24891@wgmdd8.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0508121424500.24891%40wgmdd8.biozentrum.uni-wuerzburg.de

```
Hi,

big was my surprise when my daily routine of "git pull" && "make test" 
failed. "git bisect" revealed that commit 8e832e: "String comparison of 
test is done with '=', not '=='." was the culprit.

But it isn't. The version of diff present on my iBook (OS 10.2.8) does not 
work properly in this case:

	(echo a; echo b | tr -d '\012') >frotz.2
	(echo a; echo c; echo b | tr -d '\012') >frotz.3
	diff -u frotz.2 frotz.3

yields

	--- a1  2005-08-12 14:24:19.000000000 +0200
	+++ a2  2005-08-12 14:24:27.000000000 +0200
	@@ -1,2 +1,3 @@
	 a
	+c
	 b

Note the missing "\ No newline at end of file". The same happens on 
sourceforge's compile farm's OS 10.1 server, but not on its OS 10.2 
server.

How to go about that? Silently ignore the missing line in apply.c? Force 
users to update their diff to a sane version?

Ciao,
Dscho

```

## Junio C Hamano, 2005-08-12 15:46

Subject: Re: git reveals a bug in (some versions) BSD diff
Message-ID: <7vd5ojxiny.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5ojxiny.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0508121424500.24891@wgmdd8.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Note the missing "\ No newline at end of file". The same happens on 
> sourceforge's compile farm's OS 10.1 server, but not on its OS 10.2 
> server.
>
> How to go about that? Silently ignore the missing line in apply.c? Force 
> users to update their diff to a sane version?

Hmph.  We could tackle this two ways.  We probably _could_
special case the trailing newline case if this problem is
widespread, but a more general solution would be to teach
git-apply '--fuzz'.  On the other hand, we could configure to
use gdiff (or whatever GNU diff is called on those hosts with
broken diff command) at the build time.  Probably it would be
the bast to have an explicit option --fuzz to git-apply.

```

## Johannes Schindelin, 2005-08-12 16:04

Subject: Re: git reveals a bug in (some versions) BSD diff
Message-ID: <Pine.LNX.4.63.0508121801310.26333@wgmdd8.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0508121801310.26333%40wgmdd8.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vd5ojxiny.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Fri, 12 Aug 2005, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Note the missing "\ No newline at end of file". The same happens on 
> > sourceforge's compile farm's OS 10.1 server, but not on its OS 10.2 
> > server.
> >
> > How to go about that? Silently ignore the missing line in apply.c? Force 
> > users to update their diff to a sane version?
> 
> Hmph.  We could tackle this two ways.  We probably _could_
> special case the trailing newline case if this problem is
> widespread, but a more general solution would be to teach
> git-apply '--fuzz'.  On the other hand, we could configure to
> use gdiff (or whatever GNU diff is called on those hosts with
> broken diff command) at the build time.  Probably it would be
> the bast to have an explicit option --fuzz to git-apply.

I'd prefer to deprecate that diff program by telling so in the test. 
Something along the lines "blabla. If this fails, chances are you have a 
borked diff. Try GNU diff..."

Ciao,
Dscho

BTW: On my system, gdiff does not exist.

```

## Junio C Hamano, 2005-08-12 16:30

Subject: Re: git reveals a bug in (some versions) BSD diff
Message-ID: <7vk6irw219.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vk6irw219.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0508121801310.26333@wgmdd8.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> I'd prefer to deprecate that diff program by telling so in the test. 
> Something along the lines "blabla. If this fails, chances are you have a 
> borked diff. Try GNU diff..."

Wouldn't it give the people with broken diff a false impression
that their "git diff" actually produces a good result when it
does not?

```
