You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by David Kimdon <dw...@debian.org> on 2003/06/02 03:42:49 UTC

[patch] : fix broken diff output

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 <je...@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);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [patch] : fix broken diff output

Posted by Branko Čibej <br...@xbc.nu>.
Bill Rees wrote:

>----- Original Message -----
>From: "Branko Čibej" <br...@xbc.nu>
>To: "David Kimdon" <dw...@debian.org>
>Cc: <de...@subversion.tigris.org>; <19...@bugs.debian.org>
>Sent: Monday, June 02, 2003 10:46 PM
>Subject: Re: [patch] : fix broken diff output
>
>
>David Kimdon wrote:
>
>  
>
>>Patch based on suggestion from John Lenz <je...@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.
>>
>>    
>>
>> They accept spaces, but not tabs? How's that for consistency...
>
>If you are on a Windows box filenames may contain spaces but not tabs so if
>you want to run patch you need to support spaces but not tabs
>  
>
Of course. And I do concede that spaces in filenames are more common
than tabs. But I've seem filenames with backspaces in them on Unix. :-)

-- 
Brane Čibej   <br...@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

Re: [patch] : fix broken diff output

Posted by Bill Rees <br...@jhu.edu>.
----- Original Message -----
From: "Branko Čibej" <br...@xbc.nu>
To: "David Kimdon" <dw...@debian.org>
Cc: <de...@subversion.tigris.org>; <19...@bugs.debian.org>
Sent: Monday, June 02, 2003 10:46 PM
Subject: Re: [patch] : fix broken diff output


David Kimdon wrote:

>Patch based on suggestion from John Lenz <je...@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.
>
They accept spaces, but not tabs? How's that for consistency...

If you are on a Windows box filenames may contain spaces but not tabs so if
you want to run patch you need to support spaces but not tabs

--
Brane Čibej   <br...@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





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [patch] : fix broken diff output

Posted by Branko Čibej <br...@xbc.nu>.
David Kimdon wrote:

>Patch based on suggestion from John Lenz <je...@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.
>
They accept spaces, but not tabs? How's that for consistency...

The patch itself looks fine. I'll commit it later today, when I get the
time.


-- 
Brane Čibej   <br...@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

Re: [patch] : fix broken diff output

Posted by Branko Čibej <br...@xbc.nu>.
Branko Čibej wrote:

>Committed in revision 4146.
>  
>
Yikes. 6146 is correct.

-- 
Brane Čibej   <br...@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

Re: [patch] : fix broken diff output

Posted by Branko Čibej <br...@xbc.nu>.
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 <je...@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   <br...@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