[packages/patch] - rel 2; fixes from upstream git

arekm arekm at pld-linux.org
Fri Sep 14 12:47:39 CEST 2012


commit 01b9655d7e6839d073b9152813fe6d7b7bc9c6c4
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Fri Sep 14 12:47:36 2012 +0200

    - rel 2; fixes from upstream git

 patch-git.patch | 344 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 patch.spec      |   4 +-
 2 files changed, 347 insertions(+), 1 deletion(-)
---
diff --git a/patch.spec b/patch.spec
index 090d961..e134cbf 100644
--- a/patch.spec
+++ b/patch.spec
@@ -8,12 +8,13 @@ Summary(tr.UTF-8):	GNU yama yardımcı programları
 Summary(uk.UTF-8):	Утиліта GNU patch, для модифікації/апгрейду файлів
 Name:		patch
 Version:	2.7
-Release:	1
+Release:	2
 License:	GPL v2+
 Group:		Applications/Text
 Source0:	http://ftp.gnu.org/gnu/patch/%{name}-%{version}.tar.bz2
 # Source0-md5:	1f3a075ea06705f194a2a4ce7045f072
 Source1:	%{name}.1.pl
+Patch0:		%{name}-git.patch
 URL:		http://www.gnu.org/software/patch/
 BuildRequires:	autoconf >= 2.57
 BuildRequires:	automake
@@ -71,6 +72,7 @@ Patch - це програма, яка допомогає в модифікаці
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %{__aclocal} -I m4
diff --git a/patch-git.patch b/patch-git.patch
new file mode 100644
index 0000000..6991488
--- /dev/null
+++ b/patch-git.patch
@@ -0,0 +1,344 @@
+diff --git a/NEWS b/NEWS
+index 997a726..6e90635 100644
+--- a/NEWS
++++ b/NEWS
+@@ -80,6 +80,7 @@ Changes in version 2.6:
+   particularly with Perforce.)
+ * Handle missing timestamps better.
+ * Various bug fixes.
++* Switch to GNU General Public License version 3.
+ 
+ Changes in versions 2.5.8 and 2.5.9: bug fixes only.
+ 
+diff --git a/README b/README
+index 9da2bcd..c206370 100644
+--- a/README
++++ b/README
+@@ -50,15 +50,13 @@ Foundation, Inc.
+ 
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+-the Free Software Foundation; either version 2, or (at your option)
+-any later version.
++the Free Software Foundation, either version 3 of the License, or
++(at your option) any later version.
+ 
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+-See the GNU General Public License for more details.
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+-along with this file; see the file COPYING.
+-If not, write to the Free Software Foundation,
+-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++along with this program.  If not, see <http://www.gnu.org/licenses/>.
+diff --git a/m4/xattr.m4 b/m4/xattr.m4
+index 7691177..48b08c3 100644
+--- a/m4/xattr.m4
++++ b/m4/xattr.m4
+@@ -28,7 +28,7 @@ AC_DEFUN([gl_FUNC_XATTR],
+       AC_SEARCH_LIBS([attr_copy_file], [attr],
+                      [test "$ac_cv_search_attr_copy_file" = "none required" ||
+                         LIB_XATTR=$ac_cv_search_attr_copy_file])
+-      AC_CHECK_FUNCS([attr_copy_file])
++      AC_CHECK_FUNCS([attr_copy_file attr_copy_action])
+       LIBS=$xattr_saved_LIBS
+       if test $ac_cv_func_attr_copy_file = yes; then
+         use_xattr=yes
+diff --git a/src/common.h b/src/common.h
+index b1e6c9e..23a4091 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -91,9 +91,9 @@ XTERN char const * TMPINNAME;
+ XTERN char const * TMPOUTNAME;
+ XTERN char const * TMPPATNAME;
+ 
+-XTERN int TMPINNAME_needs_removal;
+-XTERN int TMPOUTNAME_needs_removal;
+-XTERN int TMPPATNAME_needs_removal;
++XTERN bool TMPINNAME_needs_removal;
++XTERN bool TMPOUTNAME_needs_removal;
++XTERN bool TMPPATNAME_needs_removal;
+ 
+ #ifdef DEBUGGING
+ XTERN int debug;
+diff --git a/src/inp.c b/src/inp.c
+index 6387587..dbc3f5d 100644
+--- a/src/inp.c
++++ b/src/inp.c
+@@ -356,7 +356,7 @@ plan_b (char const *filename)
+     {
+       tifd = make_tempfile (&TMPINNAME, 'i', NULL, O_RDWR | O_BINARY,
+ 			    S_IRUSR | S_IWUSR);
+-      TMPINNAME_needs_removal = 1;
++      TMPINNAME_needs_removal = true;
+     }
+   i = 0;
+   len = 0;
+diff --git a/src/patch.c b/src/patch.c
+index febfd42..0bce8fb 100644
+--- a/src/patch.c
++++ b/src/patch.c
+@@ -48,14 +48,14 @@ static void init_output (struct outstate *);
+ static FILE *open_outfile (char const *);
+ static void init_reject (char const *);
+ static void reinitialize_almost_everything (void);
+-static void remove_if_needed (char const *, int *);
++static void remove_if_needed (char const *, bool *);
+ static void usage (FILE *, int) __attribute__((noreturn));
+ 
+ static void abort_hunk (char const *, bool, bool);
+ static void abort_hunk_context (bool, bool);
+ static void abort_hunk_unified (bool, bool);
+ 
+-static void output_file (char const *, int *, const struct stat *, char const *,
++static void output_file (char const *, bool *, const struct stat *, char const *,
+ 			 const struct stat *, mode_t, bool);
+ 
+ static void init_files_to_delete (void);
+@@ -95,7 +95,7 @@ static FILE *rejfp;  /* reject file pointer */
+ static char const *patchname;
+ static char *rejname;
+ static char const * TMPREJNAME;
+-static int TMPREJNAME_needs_removal;
++static bool TMPREJNAME_needs_removal;
+ 
+ static lin maxfuzz = 2;
+ 
+@@ -297,8 +297,9 @@ main (int argc, char **argv)
+ 
+       tmpoutst.st_size = -1;
+       outfd = make_tempfile (&TMPOUTNAME, 'o', outname,
+-			     O_WRONLY | binary_transput, instat.st_mode);
+-      TMPOUTNAME_needs_removal = 1;
++			     O_WRONLY | binary_transput,
++			     instat.st_mode & S_IRWXUGO);
++      TMPOUTNAME_needs_removal = true;
+       if (diff_type == ED_DIFF) {
+ 	outstate.zero_output = false;
+ 	somefailed |= skip_rest_of_patch;
+@@ -507,6 +508,7 @@ main (int argc, char **argv)
+ 		  && ! (merge && somefailed))
+ 		{
+ 		  mismatch = true;
++		  somefailed = true;
+ 		  if (verbosity != SILENT)
+ 		    say ("File %s is not empty after patch, as expected\n",
+ 			 quotearg (outname));
+@@ -1556,7 +1558,7 @@ init_reject (char const *outname)
+   int fd;
+   fd = make_tempfile (&TMPREJNAME, 'r', outname, O_WRONLY | binary_transput,
+ 		      0666);
+-  TMPREJNAME_needs_removal = 1;
++  TMPREJNAME_needs_removal = true;
+   rejfp = fdopen (fd, binary_transput ? "wb" : "w");
+   if (! rejfp)
+     pfatal ("Can't open stream for file %s", quotearg (TMPREJNAME));
+@@ -1757,7 +1759,7 @@ struct file_to_output {
+ static gl_list_t files_to_output;
+ 
+ static void
+-output_file_later (char const *from, int *from_needs_removal, const struct stat *from_st,
++output_file_later (char const *from, bool *from_needs_removal, const struct stat *from_st,
+ 		   char const *to, mode_t mode, bool backup)
+ {
+   struct file_to_output *file_to_output;
+@@ -1770,11 +1772,11 @@ output_file_later (char const *from, int *from_needs_removal, const struct stat
+   file_to_output->backup = backup;
+   gl_list_add_last (files_to_output, file_to_output);
+   if (from_needs_removal)
+-    *from_needs_removal = 0;
++    *from_needs_removal = false;
+ }
+ 
+ static void
+-output_file_now (char const *from, int *from_needs_removal,
++output_file_now (char const *from, bool *from_needs_removal,
+ 		 const struct stat *from_st, char const *to,
+ 		 mode_t mode, bool backup)
+ {
+@@ -1791,7 +1793,7 @@ output_file_now (char const *from, int *from_needs_removal,
+ }
+ 
+ static void
+-output_file (char const *from, int *from_needs_removal,
++output_file (char const *from, bool *from_needs_removal,
+ 	     const struct stat *from_st, char const *to,
+ 	     const struct stat *to_st, mode_t mode, bool backup)
+ {
+@@ -1858,13 +1860,13 @@ output_files (struct stat const *st)
+   while (gl_list_iterator_next (&iter, &elt, NULL))
+     {
+       const struct file_to_output *file_to_output = elt;
+-      int from_needs_removal = 1;
++      bool from_needs_removal = true;
+       struct stat const *from_st = &file_to_output->from_st;
+ 
+       output_file_now (file_to_output->from, &from_needs_removal,
+ 		       from_st, file_to_output->to,
+ 		       file_to_output->mode, file_to_output->backup);
+-      if (from_needs_removal)
++      if (file_to_output->to && from_needs_removal)
+ 	unlink (file_to_output->from);
+ 
+       if (st && st->st_dev == from_st->st_dev && st->st_ino == from_st->st_ino)
+@@ -1915,12 +1917,12 @@ fatal_exit (int sig)
+ }
+ 
+ static void
+-remove_if_needed (char const *name, int *needs_removal)
++remove_if_needed (char const *name, bool *needs_removal)
+ {
+   if (*needs_removal)
+     {
+       unlink (name);
+-      *needs_removal = 0;
++      *needs_removal = false;
+     }
+ }
+ 
+diff --git a/src/pch.c b/src/pch.c
+index 9661be2..551099e 100644
+--- a/src/pch.c
++++ b/src/pch.c
+@@ -138,7 +138,7 @@ open_patch_file (char const *filename)
+ 	size_t charsread;
+ 	int fd = make_tempfile (&TMPPATNAME, 'p', NULL, O_RDWR | O_BINARY, 0);
+ 	FILE *read_pfp = pfp;
+-	TMPPATNAME_needs_removal = 1;
++	TMPPATNAME_needs_removal = true;
+ 	pfp = fdopen (fd, "w+b");
+ 	if (! pfp)
+ 	  pfatal ("Can't open stream for file %s", quotearg (TMPPATNAME));
+@@ -2350,7 +2350,7 @@ get_ed_command_letter (char const *line)
+ 
+ void
+ do_ed_script (char const *inname, char const *outname,
+-	      int *outname_needs_removal, FILE *ofp)
++	      bool *outname_needs_removal, FILE *ofp)
+ {
+     static char const editor_program[] = EDITOR_PROGRAM;
+ 
+@@ -2361,7 +2361,7 @@ do_ed_script (char const *inname, char const *outname,
+     if (! dry_run && ! skip_rest_of_patch) {
+ 	int exclusive = *outname_needs_removal ? 0 : O_EXCL;
+ 	assert (! inerrno);
+-	*outname_needs_removal = 1;
++	*outname_needs_removal = true;
+ 	copy_file (inname, outname, 0, exclusive, instat.st_mode, true);
+ 	sprintf (buf, "%s %s%s", editor_program,
+ 		 verbosity == VERBOSE ? "" : "- ",
+diff --git a/src/pch.h b/src/pch.h
+index e545cb1..0c7ff62 100644
+--- a/src/pch.h
++++ b/src/pch.h
+@@ -43,7 +43,7 @@ size_t pch_line_len (lin) _GL_ATTRIBUTE_PURE;
+ const char *pch_name(enum nametype) _GL_ATTRIBUTE_PURE;
+ bool pch_copy (void) _GL_ATTRIBUTE_PURE;
+ bool pch_rename (void) _GL_ATTRIBUTE_PURE;
+-void do_ed_script (char const *, char const *, int *, FILE *);
++void do_ed_script (char const *, char const *, bool *, FILE *);
+ void open_patch_file (char const *);
+ void re_patch (void);
+ void set_hunkmax (void);
+diff --git a/src/util.c b/src/util.c
+index e8e2ad4..305e695 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -196,6 +196,8 @@ copy_attr_free (struct error_context *ctx, char const *str)
+ {
+ }
+ 
++#ifdef HAVE_ATTR_COPY_ACTION
++
+ static int
+ copy_attr_check (const char *name, struct error_context *ctx)
+ {
+@@ -203,6 +205,10 @@ copy_attr_check (const char *name, struct error_context *ctx)
+ 	return action == 0 || action == ATTR_ACTION_PERMISSIONS;
+ }
+ 
++#else
++#define copy_attr_check NULL
++#endif
++
+ static int
+ copy_attr (char const *src_path, char const *dst_path)
+ {
+@@ -430,7 +436,7 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original)
+    Back up TO if BACKUP is true.  */
+ 
+ void
+-move_file (char const *from, int *from_needs_removal,
++move_file (char const *from, bool *from_needs_removal,
+ 	   struct stat const *fromst,
+ 	   char const *to, mode_t mode, bool backup)
+ {
+@@ -525,7 +531,7 @@ move_file (char const *from, int *from_needs_removal,
+ 	  if ((0 < to_errno
+ 	       || (to_errno == 0 && to_st.st_nlink <= 1))
+ 	      && from_needs_removal)
+-	    *from_needs_removal = 0;
++	    *from_needs_removal = false;
+ 	}
+     }
+   else if (! backup)
+diff --git a/src/util.h b/src/util.h
+index d1bf495..f0d20aa 100644
+--- a/src/util.h
++++ b/src/util.h
+@@ -58,7 +58,7 @@ void init_backup_hash_table (void);
+ void init_time (void);
+ void xalloc_die (void) __attribute__ ((noreturn));
+ void create_backup (char const *, const struct stat *, bool);
+-void move_file (char const *, int *, struct stat const *, char const *, mode_t, bool);
++void move_file (char const *, bool *, struct stat const *, char const *, mode_t, bool);
+ void read_fatal (void) __attribute__ ((noreturn));
+ void remove_prefix (char *, size_t);
+ void removedirs (char const *);
+diff --git a/tests/create-delete b/tests/create-delete
+index 9a6e1bb..7eed11f 100644
+--- a/tests/create-delete
++++ b/tests/create-delete
+@@ -176,12 +176,37 @@ EOF
+ echo data > target
+ cat > p.diff <<EOF
+ diff --git a/target b/target
+-index 1..0
++deleted file mode 100644
++index 1269488..0000000
+ EOF
+ 
+ check 'patch -p1 -b < p.diff || echo status: $?' <<EOF
+ patching file target
+ File target is not empty after patch, as expected
++status: 1
++EOF
++
++check 'cat target' <<EOF
++data
++EOF
++
++# Patch creates a backup file even when the original file remains unchanged:
++check 'cat target.orig' <<EOF
++data
++EOF
++
++cat > p.diff <<EOF
++diff --git a/target b/target
++deleted file mode 100644
++index 1269488..0000000
++--- a/target
+++++ /dev/null
++@@ -1 +0,0 @@
++-data
++EOF
++
++check 'patch -p1 -b -f < p.diff || echo status: $?' <<EOF
++patching file target
+ EOF
+ 
+ ncheck 'test ! -e target'
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/patch.git/commitdiff/01b9655d7e6839d073b9152813fe6d7b7bc9c6c4



More information about the pld-cvs-commit mailing list