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
===================================================================
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 -0000
@@ -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
===================================================================
--- 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

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

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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to