Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jul 2012 23:15:32 +0100
From:      Matthew Seaman <matthew@FreeBSD.org>
To:        freebsd-ports <freebsd-ports@FreeBSD.org>
Subject:   SVN bug with embedded carriage returns.
Message-ID:  <5011C184.8010906@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig061CFE66AD9AD6830A8C1ECB
Content-Type: multipart/mixed; boundary="------------020802040009060003030807"

This is a multi-part message in MIME format.
--------------020802040009060003030807
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable


Here's an amusing little SVN bug I chanced upon to keep you all on your
toes.

Files with embedded carriage returns (that's ascii character 13,
variously known as \r, ^M, \015, \x0D) can result in subversion
producing a broken diff.

Eg.

This is what CVS produced (which is correct, and patch(1) will apply it
perfectly happily):

Index: games/linux-enemyterritory-etpub/Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/ports/games/linux-enemyterritory-etpub/Makefile,v
retrieving revision 1.12
diff -u -u -r1.12 Makefile
--- games/linux-enemyterritory-etpub/Makefile   12 Jun 2012 16:35:41
-0000      1.12
+++ games/linux-enemyterritory-etpub/Makefile   13 Jun 2012 21:02:23 -000=
0
@@ -40,7 +40,7 @@

 pre-patch:
        @${FIND} ${WRKSRC} -type f -exec ${SH} -c \
-               '${FILE} "$$0" | ${GREP} -q text && \
+               '${FILE_CMD} "$$0" | ${GREP} -q text && \
                ${REINPLACE_CMD} -i "" -e "s/^M$$//" "$$0"' {} \;

 do-build:

Whereas this is what subversion generates:

% svn diff games/linux-enemyterritory-etpub | cat -v
Index: games/linux-enemyterritory-etpub/Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- games/linux-enemyterritory-etpub/Makefile	(revision 301564)
+++ games/linux-enemyterritory-etpub/Makefile	(working copy)
@@ -40,7 +40,7 @@

 pre-patch:
 	@${FIND} ${WRKSRC} -type f -exec ${SH} -c \
-		'${FILE} "$$0" | ${GREP} -q text && \
+		'${FILE_CMD} "$$0" | ${GREP} -q text && \
 		${REINPLACE_CMD} -i "" -e "s/^M $$//" "$$0"' {} \;

Notice the space inserted after ^M and the missing line of context at
the end.

Before you ask, see the attached for all the places embedded carriage
returns occur in the ports, where they *aren't* from files
with DOS style end-of-lines.  The portlint ones are particularly
amusing, as carriage return is generally spelled \r in perl.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.
PGP: http://www.infracaninophile.co.uk/pgpkey


--------------020802040009060003030807
Content-Type: text/plain; charset=UTF-8;
 name="embedded-CRs.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="embedded-CRs.txt"

% pcregrep -n -I --exclude_dir=3D.svn -r '\r[^\n]' . | cat -v
=2E/security/p5-Crypt-RC6/Makefile:22:	${REINPLACE_CMD} -e 's/^M//' ${WRK=
SRC}/RC6.pm
=2E/ftp/urlgfe/Makefile:37:		's|^M$$||g'
=2E/ftp/urlgfe/Makefile:41:	@${REINPLACE_CMD} -e 's|^M$$||g ; s|urlgfe_ic=
on|urlgfe-icon|g ; \
=2E/print/mp-letter/Makefile:34:	@${REINPLACE_CMD} -e 's/<iostream\.h>/<i=
ostream>^Musing namespace std;/' \
=2E/Mk/bsd.port.mk:3574:			${XARGS} -0 ${REINPLACE_CMD} -i '' -e 's/^M$$/=
/'
=2E/Mk/bsd.port.mk:3579:	@${REINPLACE_CMD} -i '' -e 's/^M$$//' ${WRKSRC}/=
${f}
=2E/Mk/bsd.port.mk:3584:			${XARGS} -0 ${REINPLACE_CMD} -i '' -e 's/^M$$/=
/'
=2E/math/sedumi/Makefile:28:		cd ${WRKSRC} ; ${REINPLACE_CMD} -e 's#^M##g=
' $$i ; \
=2E/math/spar/files/patch-lib::randist::rand.c:9: ^Mvoid ^M
=2E/textproc/clit/Makefile:37:	@${FIND} ${WRKDIR} -name *.c -or -name *.h=
 | ${XARGS} ${REINPLACE_CMD} -e 's|^M||'
=2E/databases/jasperserver/Makefile:172:		${XARGS} -0 ${SED} -i '' -e 's/=
^M$$//'
=2E/japanese/FreeWnn-server/files/patch-configure:29274:+ac_cr=3D'^M'
=2E/japanese/FreeWnn-lib/files/patch-configure:29274:+ac_cr=3D'^M'
=2E/graphics/povray31/files/script:3:	sed -e 's/^M$//g' $i > /tmp/xfer	# =
^M is Ctrl+M
=2E/graphics/picturebook/files/patch-ag:115: /* :about to start capture a=
gain^M */
=2E/x11-toolkits/libgtk-java/Makefile:44:	@${REINPLACE_CMD} -e 's|^M||' $=
{WRKSRC}/gtk2-java.pc.in
=2E/x11-toolkits/ruby-wx/Makefile:36:	@${FIND} ${WRKSRC} -name *.t | ${XA=
RGS} ${REINPLACE_CMD} -e 's|^M||'
=2E/irc/xchat-mircryption/Makefile:42:		-e 's|^M||' \
=2E/irc/xchat-fish/Makefile:39:		-e 's|^M||' \
=2E/sysutils/weedit/files/patch-utils__readdb.c:7:-^Mint main(unsigned in=
t argc, char **argv)
=2E/audio/holyshout/files/patch-holyshout.c:269:-    if (data[0]=3D=3D'\0=
' || data[0]=3D=3D'\n' || data[0]=3D=3D'^M') return 0 ;
=2E/net-im/amsn/Makefile:52:	@${FIND} ${WRKSRC} -name '*.c' -or -name '*.=
h' | ${XARGS} ${REINPLACE_CMD} -e 's|^M||'
=2E/games/linux-enemyterritory-etpub/Makefile:44:		${REINPLACE_CMD} -i ""=
 -e "s/^M$$//" "$$0"' {} \;
=2E/mail/popfile/Makefile:83:	${REINPLACE_CMD} -i '' -e "s,^#!/usr/bin/pe=
rl^M$$,#!${PERL}," ${WRKSRC}/popfile.pl
=2E/multimedia/subtools/Makefile:25:	@${REINPLACE_CMD} -e 's,^M,,g;s,^.*#=
!.*python.*$$,#!${PYTHON_CMD},' ${WRKSRC}/*
=2E/x11/libgnome-java/Makefile:47:	@${REINPLACE_CMD} -e 's|^M||g' \
=2E/ports-mgmt/portlint/src/portlint.pl:634:		if (/^M$/) {
=2E/ports-mgmt/portlint/src/portlint.pl:1181:	if ($whole =3D~ /^M/) {
=2E/ports-mgmt/portlint/src/portlint.pl:1830:	if ($whole =3D~ /^M/ || $wh=
ole =3D~ /:cntrl:/) {
=2E/x11-themes/kde-icons-noia/Makefile.icons:41:		-e 's|^M||' \

--------------020802040009060003030807--

--------------enig061CFE66AD9AD6830A8C1ECB
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlARwY0ACgkQ8Mjk52CukIwg4wCfTvJQ5SaI6wX9kG+uhbXDQHSw
FL0AnjBNzkRTHbG5r4NMjRf5kWwE0kot
=dhXf
-----END PGP SIGNATURE-----

--------------enig061CFE66AD9AD6830A8C1ECB--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5011C184.8010906>