[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: BAD! 'svn diff' exits with 0 when some difference exists.

From: Branko Čibej <brane_at_xbc.nu>
Date: 2006-08-19 22:10:15 CEST

Peter Samuelson wrote:
> [Ben Collins-Sussman]
>
>> I think this is intentional; when the 'svn' binary returns 0, it
>> means "no error happened", and non-zero means "an error happened".
>> It's certainly not an error to print out a difference! I might argue
>> that 'cvs diff' is being a bit strange when it does this.
>>
>
> This has come up before (issue #2513), and it's been noted that the
> Unix utility 'diff' also returns 1 for differences found, 2 for error.
> So it's not CVS being weird, it's Unix diff being weird and CVS playing
> along.
>

Plain diff basically mimics cmp in this respect, and behaves as it does
on the assumption that it makes it easier to use in tests in shell
scripts; e.g.,

    if [ cmp foo bar ]; then echo foo and bar differ; fi

The assumption is of course wrong, because such a test won't notice the
difference between a 1 and 2 exit code, so the test has to be more complex.

> I think it'd be better for svn diff to agree with diff and cvs diff,
> but I don't know whether that would break your 1.x compatibility
> contract.
>

Yes, it would.

>>> If 'svn diff' always return 0, it will be programmatically hard to
>>> know when difference occurs and stop the make system.
>>>
>
>
>> How about just looking at stdout? If anything is printed to stdout,
>> there's a difference. Doesn't that make more sense anyway?
>>
>
> Alternatively, 'svn status' is intended to be machine-parseable.
>

Yes, but 'svn status' doesn't have all the different modes that 'svn
diff' has, so they're not interchangeable.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Aug 19 22:10:37 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.