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

[PATCH] diff label problems

From: Gustavo Niemeyer <niemeyer_at_conectiva.com>
Date: 2002-10-19 02:05:25 CEST

There's an interesting diff behavior which is affecting Subversion.

Please, have a look at these two executions:

% diff -u -L dir/file tmp.8380.00002 tmp.15728.00002
--- dir/file
+++ tmp.15728.00002 Fri Oct 18 20:27:00 2002
@@ -0,0 +1 @@
+foo

% diff -u -L dir/file -L dir/file tmp.8380.00002 tmp.15728.00002
--- dir/file
+++ dir/file
@@ -0,0 +1 @@
+foo

Noticed the diff header? Subversion is currently using the first
form:

% svn diff file:///svnroot/test_at_12 file:///svnroot/test_at_13
Index: dir/file
===================================================================
--- dir/file
+++ tmp.15136.00001 Fri Oct 18 20:46:01 2002
@@ -0,0 +1 @@
+foo

At first, this doesn't look like a big problem. But have a look at
this excerpt from the patch man page:

   If no named files exist, no RCS, ClearCase, or SCCS
   master was found, some names are given, patch is not
   conforming to POSIX, and the patch appears to create a
   file, patch selects the best name requiring the cre­
   ation of the fewest directories.

Now, guess what happens if the directory "dir" in the patch above
doesn't exist. :-)

This small patch fixes this behavior:

* subversion/libsvn_subr/io.c
  (svn_io_run_diff): Repeat -L option, forcing usage of label for
  both files.

Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c
+++ subversion/libsvn_subr/io.c 2002-10-18 21:01:11.000000000 -0300
@@ -1401,7 +1401,7 @@
     nargs += 1; /* -u */
 
   if (label != NULL)
- nargs += 2; /* the -L and the label itself */
+ nargs += 4; /* the -L and the label itself, two times */
 
   args = apr_palloc (subpool, nargs * sizeof(char *));
 
@@ -1421,6 +1421,8 @@
     {
       args[i++] = "-L";
       args[i++] = label;
+ args[i++] = "-L";
+ args[i++] = label;
     }
 
   args[i++] = from;

-- 
Gustavo Niemeyer
[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 19 02:06:05 2002

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.