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

Re: [patch] : fix broken diff output

From: Branko Čibej <brane_at_xbc.nu>
Date: 2003-06-05 00:47:51 CEST

Committed in revision 4146.

David Kimdon wrote:

>Hi,
>
>As described in http://bugs.debian.org/195334 new versions of patch
>accept spaces in filenames. This causes patch to behave incorrectly
>on the output of a subversion diff between two branches. If this
>patch looks good, and is something we want to fix, I'll commit.
>
>-David
>
>Exhibit A: reproduction recipe
>
>svnadmin create repos
>svn mkdir -m '' file://`pwd`/repos/trunk
>svn mkdir -m '' file://`pwd`/repos/branches
>svn co file://`pwd`/repos/trunk wc
>touch wc/main.c
>svn add wc/main.c
>svn commit -m '' wc/
>svn cp -m '' file://`pwd`/repos/trunk/ file://`pwd`/repos/branches/dev/
>svn co file://`pwd`/repos/branches/dev
>echo 1 >> dev/main.c
>svn commit -m '' dev/main.c
>svn diff file://`pwd`/repos/trunk file://`pwd`/repos/branches/dev > diff
>
>Up to now all looks ok:
>
>$ cat ../diff
>Index: main.c
>===================================================================
>--- main.c (.../trunk) (revision 5)
>+++ main.c (.../branches/dev) (revision 5)
>@@ -0,0 +1 @@
>+1
>$ patch -p0 < ../diff
>patching file 'main.c (.../trunk)'
>$ ls -1
>main.c
>main.c (...
>$ ls "main.c (..."
>trunk)
>$
>
>But those filenames are not what we wanted.
>
>Exhibit B : proposed fix
>
>Patch based on suggestion from John Lenz <jelenz@students.wisc.edu>
>
>* subversion/libsvn_client/diff.c (diff_file_changed) : Delimit filename with
> tab instead of space since some versions of patch accept space as a valid
> character in a filename.
>
>Index: subversion/libsvn_client/diff.c
>===================================================================
>--- subversion/libsvn_client/diff.c (revision 6108)
>+++ subversion/libsvn_client/diff.c (working copy)
>@@ -243,16 +243,16 @@
> if (path1[0] == '\0')
> path1 = apr_psprintf (subpool, "%s", path);
> else if (path1[0] == '/')
>- path1 = apr_psprintf (subpool, "%s (...%s)", path, path1);
>+ path1 = apr_psprintf (subpool, "%s\t(...%s)", path, path1);
> else
>- path1 = apr_psprintf (subpool, "%s (.../%s)", path, path1);
>+ path1 = apr_psprintf (subpool, "%s\t(.../%s)", path, path1);
>
> if (path2[0] == '\0')
> path2 = apr_psprintf (subpool, "%s", path);
> else if (path2[0] == '/')
>- path2 = apr_psprintf (subpool, "%s (...%s)", path, path2);
>+ path2 = apr_psprintf (subpool, "%s\t(...%s)", path, path2);
> else
>- path2 = apr_psprintf (subpool, "%s (.../%s)", path, path2);
>+ path2 = apr_psprintf (subpool, "%s\t(.../%s)", path, path2);
>
> label1 = diff_label (path1, rev1, subpool);
> label2 = diff_label (path2, rev2, subpool);
>
>

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jun 5 00:46:40 2003

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.