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

Re: the patch/diff saga continues.

From: Karl Fogel <kfogel_at_collab.net>
Date: 2001-06-28 19:04:37 CEST

Joe Orton <jorton@btconnect.com> writes:
> > `local_tests.py 7` ("basic update") still fails on FreeBSD, even now
> > that we're requiring and using GNU patch.
>
> It looks like FreeBSD are patching GNU diff to alter this behaviour,
> check the history out:
>
> http://www.FreeBSD.org/cgi/cvsweb.cgi/src/contrib/diff/util.c

Apparently they weren't aware that GNU diff's

   \No newline at end of file

is a special marker recognized by GNU patch, which enables the pair to
diff and patch text files that don't end with a newline. Or if they
were aware, it wasn't a priority for them (but nothing in the log
comments indicates that they knew they were breaking compatibility
with GNU patch, but then again they don't ship with GNU patch...).

It's looking like the only reliable answer is, after all, to have
Subversion manually compensate for the lack of final newline in text
files. That's a bit clumsy, but will work 100% of the time... Then at
least we wouldn't need to require GNU patch either, and the autoconf
test Ben spent so much time writing could be removed. <ducks>

Can anyone think of a better solution than this? Sigh. :-)

By the way, this node from the GNU diff info pages explains the
situation in some more detail:

File: diff.info, Node: Incomplete Lines, Next: Projects, Prev: Invoking sdiff, Up: Top

Incomplete Lines
****************

   When an input file ends in a non-newline character, its last line is
called an "incomplete line" because its last character is not a
newline. All other lines are called "full lines" and end in a newline
character. Incomplete lines do not match full lines unless differences
in white space are ignored (*note White Space::).

   An incomplete line is normally distinguished on output from a full
line by a following line that starts with `\'. However, the RCS format
(*note RCS::) outputs the incomplete line as-is, without any trailing
newline or following line. The side by side format normally represents
incomplete lines as-is, but in some cases uses a `\' or `/' gutter
marker; *Note Side by Side::. The if-then-else line format preserves a
line's incompleteness with `%L', and discards the newline with `%l';
*Note Line Formats::. Finally, with the `ed' and forward `ed' output
formats (*note Output Formats::) `diff' cannot represent an incomplete
line, so it pretends there was a newline and reports an error.

   For example, suppose `F' and `G' are one-byte files that contain
just `f' and `g', respectively. Then `diff F G' outputs

     1c1
     < f
     \ No newline at end of file
     ---
> g
     \ No newline at end of file

(The exact message may differ in non-English locales.) `diff -n F G'
outputs the following without a trailing newline:

     d1 1
     a1 1
     g

   `diff -e F G' reports two errors and outputs the following:

     1c
     g
     .

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:32 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.