rpms/patch/devel patch-best-name.patch,NONE,1.1 patch.spec,1.41,1.42

Tim Waugh twaugh at fedoraproject.org
Thu Dec 24 14:06:35 UTC 2009


Author: twaugh

Update of /cvs/pkgs/rpms/patch/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4348

Modified Files:
	patch.spec 
Added Files:
	patch-best-name.patch 
Log Message:
* Thu Dec 24 2009 Tim Waugh <twaugh at redhat.com> 2.6-2
- Applied upstream patch to prevent incorrect filename being chosen
  when adding a new file (bug #549122).


patch-best-name.patch:
 pch.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

--- NEW FILE patch-best-name.patch ---
--- patch-2.6/src/pch.c	2009-11-02 19:09:57.000000000 +0000
+++ patch-2.6-4-ge2218ac/src/pch.c	2009-12-22 23:03:27.000000000 +0000
@@ -195,23 +195,22 @@
 }
 
 static bool
-maybe_reverse (char const *name, bool nonexistent, bool empty)
+maybe_reverse (char const *name, bool nonexistent, bool is_empty)
 {
-  bool is_empty = nonexistent || empty;
-  bool r;
+  bool looks_reversed = (! is_empty) < p_says_nonexistent[reverse ^ is_empty];
 
-  r = (! is_empty) < p_says_nonexistent[reverse ^ is_empty]
-      && ok_to_reverse ("The next patch%s would %s the file %s,\nwhich %s!",
-			reverse ? ", when reversed," : "",
-			(nonexistent ? "delete"
-			 : empty ? "empty out"
-			 : "create"),
-			quotearg (name),
-			(nonexistent ? "does not exist"
-			 : empty ? "is already empty"
-			 : "already exists"));
-  reverse ^= r;
-  return r;
+  if (looks_reversed)
+    reverse ^=
+      ok_to_reverse ("The next patch%s would %s the file %s,\nwhich %s!",
+		     reverse ? ", when reversed," : "",
+		     (nonexistent ? "delete"
+		      : is_empty ? "empty out"
+		      : "create"),
+		     quotearg (name),
+		     (nonexistent ? "does not exist"
+		      : is_empty ? "is already empty"
+		      : "already exists"));
+  return looks_reversed;
 }
 
 /* True if the remainder of the patch file contains a diff of some sort. */
@@ -638,6 +637,7 @@
 
 	if (! posixly_correct)
 	  {
+	    /* The best of all existing files. */
 	    i = best_name (p_name, stat_errno);
 
 	    if (i == NONE && patch_get)
@@ -680,12 +680,10 @@
 		    }
 	      }
 
-	    if (i != NONE && st[i].st_size > 0)
-	      i0 = i;
 	    if (i0 != NONE
-		&& ! maybe_reverse (p_name[i0], i == NONE,
-				    i == NONE || st[i].st_size == 0))
-	      i = i0;
+	        && maybe_reverse (p_name[i0], i == NONE,
+				  i == NONE || st[i].st_size == 0))
+		i = i0;
 
 	    if (i == NONE && p_says_nonexistent[reverse])
 	      {
@@ -706,6 +704,7 @@
 		  if (p_name[i])
 		    distance_from_minimum[i] = newdirs[i] - newdirs_min;
 
+		/* The best of the filenames which create the fewest directories. */
 		i = best_name (p_name, distance_from_minimum);
 	      }
 	  }


Index: patch.spec
===================================================================
RCS file: /cvs/pkgs/rpms/patch/devel/patch.spec,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -p -r1.41 -r1.42
--- patch.spec	16 Nov 2009 10:05:01 -0000	1.41
+++ patch.spec	24 Dec 2009 14:06:35 -0000	1.42
@@ -1,12 +1,13 @@
 Summary: Utility for modifying/upgrading files
 Name: patch
 Version: 2.6
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2+
 URL: http://www.gnu.org/software/patch/patch.html
 Group: Development/Tools
 Source: ftp://ftp.gnu.org/gnu/patch/patch-%{version}.tar.xz
 Patch1: patch-2.5.4-sigsegv.patch
+Patch2: patch-best-name.patch
 Patch100: patch-selinux.patch
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -25,6 +26,7 @@ applications.
 %prep
 %setup -q
 %patch1 -p1 -b .sigsegv
+%patch2 -p1 -b .best-name
 %patch100 -p1 -b .selinux
 
 %build
@@ -55,6 +57,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/*/*
 
 %changelog
+* Thu Dec 24 2009 Tim Waugh <twaugh at redhat.com> 2.6-2
+- Applied upstream patch to prevent incorrect filename being chosen
+  when adding a new file (bug #549122).
+
 * Mon Nov 16 2009 Tim Waugh <twaugh at redhat.com> 2.6-1
 - 2.6.  No longer need stderr, suffix, stripcr, parse, allow-spaces,
   ifdef, program_name, or posix-backup patches.




More information about the scm-commits mailing list