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

arekm arekm at pld-linux.org
Wed Oct 1 17:46:16 CEST 2014


commit f0b7bf8ccd9c11bea3ffb49d973cf5b77e714ef0
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Wed Oct 1 17:46:13 2014 +0200

    - rel 2; add fixes from upstream git

 patch-git.patch | 436 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 patch.spec      |   4 +-
 2 files changed, 439 insertions(+), 1 deletion(-)
---
diff --git a/patch.spec b/patch.spec
index 5fcb0ab..fabfbd7 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.1
-Release:	1
+Release:	2
 License:	GPL v3+
 Group:		Applications/Text
 Source0:	http://ftp.gnu.org/gnu/patch/%{name}-%{version}.tar.xz
 # Source0-md5:	e9ae5393426d3ad783a300a338c09b72
 Source1:	%{name}.1.pl
+Patch0:		%{name}-git.patch
 URL:		http://www.gnu.org/software/patch/
 BuildRequires:	autoconf >= 2.65
 BuildRequires:	automake >= 1:1.11.2
@@ -73,6 +74,7 @@ Patch - це програма, яка допомогає в модифікаці
 
 %prep
 %setup -q
+%patch -p1
 
 %build
 %{__aclocal} -I m4
diff --git a/patch-git.patch b/patch-git.patch
new file mode 100644
index 0000000..ef4836c
--- /dev/null
+++ b/patch-git.patch
@@ -0,0 +1,436 @@
+diff --git a/NEWS b/NEWS
+index 28d0e91..42afed7 100644
+--- a/NEWS
++++ b/NEWS
+@@ -1,3 +1,9 @@
++* When a file isn't being deleted because the file contents don't match the
++  patch, the resulting message is now "Not deleting file ... as content
++  differs from patch" instead of "File ... is not empty after patch; not
++  deleting".
++* Function names in hunks (from diff -p) are now preserved in reject files.
++
+ Changes in version 2.7.1:
+ 
+ * Two critical bug fixes in the "diff --git" format support.
+diff --git a/configure.ac b/configure.ac
+index dc837d6..f078469 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -33,7 +33,7 @@ AM_CONDITIONAL([ENABLE_MERGE], [test "$enableval" != no])
+ AM_CONDITIONAL([ALPHA_VERSION],
+   [[echo "$PACKAGE_VERSION" | grep -- "-[0-9a-f][0-9a-f]*\\(-dirty\\)\\?$" >/dev/null]])
+ 
+-AM_INIT_AUTOMAKE([1.11.2 -Wall -Werror gnu dist-bzip2 dist-xz color-tests parallel-tests])
++AM_INIT_AUTOMAKE([1.11.2 -Wall gnu dist-bzip2 dist-xz color-tests parallel-tests])
+ AM_SILENT_RULES([yes])
+ 
+ AC_CONFIG_HEADER([config.h:config.hin])
+diff --git a/patch.man b/patch.man
+index c5cc5c4..2c9def5 100644
+--- a/patch.man
++++ b/patch.man
+@@ -1,14 +1,10 @@
+ .\" patch man page
+-.de Id
+-.ds Dt \\$4
+-..
+ .ds = \-\^\-
+ .de Sp
+ .if t .sp .3
+ .if n .sp
+ ..
+-.TH PATCH 1 \*(Dt GNU
+-.ta 3n
++.TH PATCH 1 "" GNU
+ .SH NAME
+ patch \- apply a diff file to an original
+ .SH SYNOPSIS
+@@ -241,7 +237,9 @@ asks for confirmation before proceeding.
+ The upshot of all this is that you should be able to say, while in a news
+ interface, something like the following:
+ .Sp
+-	\fB| patch \-d /usr/src/local/blurfl\fP
++.RS
++\fB| patch \-d /usr/src/local/blurfl\fP
++.RE
+ .Sp
+ and patch a file in the
+ .B blurfl
+@@ -445,8 +443,8 @@ This option implies \fB\*=forward\fP and does not take the
+ Interpret the patch file as a normal diff.
+ .TP
+ \fB\-N\fP  or  \fB\*=forward\fP
+-Ignore patches that seem to be reversed or already applied. It is only checked if
+-the first hunk of a patch can be reversed.
++When a patch does not apply, patch usually checks if the patch looks like it
++has been reversed.  The \fB\*=forward\fP option prevents that.
+ See also
+ .BR \-R .
+ .TP
+@@ -470,7 +468,9 @@ you keep your files in a different directory than the person who sent
+ out the patch.
+ For example, supposing the file name in the patch file was
+ .Sp
+-	\fB/u/howard/src/blurfl/blurfl.c\fP
++.RS
++\fB/u/howard/src/blurfl/blurfl.c\fP
++.RE
+ .Sp
+ setting
+ .B \-p0
+@@ -478,13 +478,17 @@ gives the entire file name unmodified,
+ .B \-p1
+ gives
+ .Sp
+-	\fBu/howard/src/blurfl/blurfl.c\fP
++.RS
++\fBu/howard/src/blurfl/blurfl.c\fP
++.RE
+ .Sp
+ without the leading slash,
+ .B \-p4
+ gives
+ .Sp
+-	\fBblurfl/blurfl.c\fP
++.RS
++\fBblurfl/blurfl.c\fP
++.RE
+ .Sp
+ and not specifying
+ .B \-p
+@@ -876,7 +880,9 @@ or
+ option.
+ Here is an example command, using Bourne shell syntax:
+ .Sp
+-	\fBLC_ALL=C TZ=UTC0 diff \-Naur gcc\-2.7 gcc\-2.8\fP
++.RS
++\fBLC_ALL=C TZ=UTC0 diff \-Naur gcc\-2.7 gcc\-2.8\fP
++.RE
+ .PP
+ Tell your recipients how to apply the patch
+ by telling them which directory to
+@@ -925,14 +931,16 @@ If the recipient is supposed to use the
+ .BI \-p N
+ option, do not send output that looks like this:
+ .Sp
+-.ft B
++.RS
++.ft CW
+ .ne 3
+-	diff \-Naur v2.0.29/prog/README prog/README
++diff \-Naur v2.0.29/prog/README prog/README
+ .br
+-	\-\^\-\^\- v2.0.29/prog/README   Mon Mar 10 15:13:12 1997
++\-\^\-\^\- v2.0.29/prog/README   Mon Mar 10 15:13:12 1997
+ .br
+-	+\^+\^+ prog/README   Mon Mar 17 14:58:22 1997
+++\^+\^+ prog/README   Mon Mar 17 14:58:22 1997
+ .ft
++.RE
+ .Sp
+ because the two file names have different numbers of slashes,
+ and different versions of
+@@ -940,14 +948,16 @@ and different versions of
+ interpret the file names differently.
+ To avoid confusion, send output that looks like this instead:
+ .Sp
+-.ft B
++.RS
++.ft CW
+ .ne 3
+-	diff \-Naur v2.0.29/prog/README v2.0.30/prog/README
++diff \-Naur v2.0.29/prog/README v2.0.30/prog/README
+ .br
+-	\-\^\-\^\- v2.0.29/prog/README   Mon Mar 10 15:13:12 1997
++\-\^\-\^\- v2.0.29/prog/README   Mon Mar 10 15:13:12 1997
+ .br
+-	+\^+\^+ v2.0.30/prog/README   Mon Mar 17 14:58:22 1997
+++\^+\^+ v2.0.30/prog/README   Mon Mar 17 14:58:22 1997
+ .ft
++.RE
+ .Sp
+ .PP
+ Avoid sending patches that compare backup file names like
+diff --git a/src/patch.c b/src/patch.c
+index 828943b..12028a9 100644
+--- a/src/patch.c
++++ b/src/patch.c
+@@ -150,6 +150,10 @@ main (int argc, char **argv)
+     else if ((version_control = getenv ("VERSION_CONTROL")))
+       version_control_context = "$VERSION_CONTROL";
+ 
++    init_backup_hash_table ();
++    init_files_to_delete ();
++    init_files_to_output ();
++
+     /* parse switches */
+     Argc = argc;
+     Argv = argv;
+@@ -162,10 +166,6 @@ main (int argc, char **argv)
+     if (make_backups | backup_if_mismatch)
+       backup_type = get_version (version_control_context, version_control);
+ 
+-    init_backup_hash_table ();
+-    init_files_to_delete ();
+-    init_files_to_output ();
+-
+     init_output (&outstate);
+     if (outfile)
+       outstate.ofp = open_outfile (outfile);
+@@ -519,7 +519,7 @@ main (int argc, char **argv)
+ 		  mismatch = true;
+ 		  somefailed = true;
+ 		  if (verbosity != SILENT)
+-		    say ("File %s is not empty after patch; not deleting\n",
++		    say ("Not deleting file %s as content differs from patch\n",
+ 			 quotearg (outname));
+ 		}
+ 
+@@ -646,8 +646,8 @@ main (int argc, char **argv)
+     if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
+       write_fatal ();
+     output_files (NULL);
+-    delete_files ();
+     cleanup ();
++    delete_files ();
+     if (somefailed)
+       exit (1);
+     return 0;
+@@ -762,7 +762,7 @@ static char const *const option_help[] =
+ "",
+ "  -D NAME  --ifdef=NAME  Make merged if-then-else output using NAME.",
+ #ifdef ENABLE_MERGE
+-"  -m  --merge  Merge using conflict markers instead of creating reject files.",
++"  --merge  Merge using conflict markers instead of creating reject files.",
+ #endif
+ "  -E  --remove-empty-files  Remove output files that are empty after patching.",
+ "",
+@@ -1237,6 +1237,7 @@ abort_hunk_unified (bool header, bool reverse)
+   lin old = 1;
+   lin lastline = pch_ptrn_lines ();
+   lin new = lastline + 1;
++  char const *c_function = pch_c_function();
+ 
+   if (header)
+     {
+@@ -1251,7 +1252,7 @@ abort_hunk_unified (bool header, bool reverse)
+   print_unidiff_range (rejfp, pch_first () + out_offset, lastline);
+   fprintf (rejfp, " +");
+   print_unidiff_range (rejfp, pch_newfirst () + out_offset, pch_repl_lines ());
+-  fprintf (rejfp, " @@\n");
++  fprintf (rejfp, " @@%s\n", c_function ? c_function : "");
+ 
+   while (pch_char (new) == '=' || pch_char (new) == '\n')
+     new++;
+diff --git a/src/util.c b/src/util.c
+index 1cc1a68..0af6013 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -1599,7 +1599,7 @@ make_tempfile (char const **name, char letter, char const *real_name,
+   int try_makedirs_errno = ENOENT;
+   char *template;
+ 
+-  if (real_name)
++  if (real_name && ! dry_run)
+     {
+       char *dirname, *basename;
+ 
+diff --git a/tests/Makefile.am b/tests/Makefile.am
+index 02fc6de..cfc4f37 100644
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -20,6 +20,7 @@ TESTS = \
+ 	asymmetric-hunks \
+ 	backup-prefix-suffix \
+ 	bad-filenames \
++	bad-usage \
+ 	concat-git-diff \
+ 	copy-rename \
+ 	corrupt-reject-files \
+@@ -49,6 +50,7 @@ TESTS = \
+ 	reject-format \
+ 	remember-backup-files \
+ 	remember-reject-files \
++	remove-directories \
+ 	symlinks \
+ 	unmodified-files
+ 
+diff --git a/tests/bad-usage b/tests/bad-usage
+new file mode 100644
+index 0000000..022eeda
+--- /dev/null
++++ b/tests/bad-usage
+@@ -0,0 +1,18 @@
++# Copyright (C) 2009, 2011-2012 Free Software Foundation, Inc.
++#
++# Copying and distribution of this file, with or without modification,
++# in any medium, are permitted without royalty provided the copyright
++# notice and this notice are preserved.
++
++. $srcdir/test-lib.sh
++
++require_cat
++use_local_patch
++use_tmpdir
++
++# ==============================================================
++
++check 'patch -px || echo "status: $?"' <<EOF
++$PATCH: **** strip count x is not a number
++status: 2
++EOF
+diff --git a/tests/create-delete b/tests/create-delete
+index 7c46166..404d99e 100644
+--- a/tests/create-delete
++++ b/tests/create-delete
+@@ -182,7 +182,7 @@ EOF
+ 
+ check 'patch -p0 < p.diff || echo status: $?' <<EOF
+ patching file target
+-File target is not empty after patch; not deleting
++Not deleting file target as content differs from patch
+ status: 1
+ EOF
+ 
+@@ -202,7 +202,7 @@ EOF
+ 
+ check 'patch -p0 < p.diff || echo status: $?' <<EOF
+ patching file target
+-File target is not empty after patch; not deleting
++Not deleting file target as content differs from patch
+ status: 1
+ EOF
+ 
+@@ -212,23 +212,27 @@ EOF
+ 
+ # --------------------------------------------------------------
+ printf '\0' > target
+-cat > p.diff <<EOF
++if ! test -s target; then
++    echo "Failed to printf a null character; skipping this test"
++else
++    cat > p.diff <<EOF
+ diff --git a/target b/target
+ deleted file mode 100644
+ index f76dd23..0000000
+ Binary files a/target and /dev/null differ
+ EOF
+ 
+-check 'patch -p1 -b < p.diff || echo status: $?' <<EOF
++    check 'patch -p1 -b < p.diff || echo status: $?' <<EOF
+ patching file target
+-File target is not empty after patch; not deleting
++Not deleting file target as content differs from patch
+ status: 1
+ EOF
+ 
+-ncheck 'test -e target'
++    ncheck 'test -e target'
+ 
+ # Patch creates a backup file even when the original file remains unchanged:
+-ncheck 'test -e target.orig'
++    ncheck 'test -e target.orig'
++fi
+ 
+ # ================================================================
+ # File not expected to become empty does become empty
+diff --git a/tests/create-directory b/tests/create-directory
+index f02ce6e..9fc3288 100644
+--- a/tests/create-directory
++++ b/tests/create-directory
+@@ -4,15 +4,14 @@
+ # in any medium, are permitted without royalty provided the copyright
+ # notice and this notice are preserved.
+ 
+-# Check whether patch correctly creates directories before creating
+-# new files.
+-
+ . $srcdir/test-lib.sh
+ 
+ use_local_patch
+ use_tmpdir
+ 
+ # ==============================================================
++# Check whether patch correctly creates directories before creating
++# new files.
+ 
+ cat > f.diff <<EOF
+ --- /dev/null
+@@ -25,3 +24,20 @@ EOF
+ check 'patch -p0 < f.diff' <<EOF
+ patching file b/newfile
+ EOF
++
++# ==============================================================
++# Make sure it doesn't create files or directories in the target
++#  location in --dry-run mode
++mkdir d
++cat > f.diff <<EOF
++--- /dev/null
+++++ d/e/f
++@@ -0,0 +1 @@
+++f
++EOF
++
++chmod u-w d
++check 'patch -p0 --dry-run < f.diff' <<EOF
++checking file d/e/f
++EOF
++chmod u+w d
+diff --git a/tests/reject-format b/tests/reject-format
+index be710f5..0b02af6 100644
+--- a/tests/reject-format
++++ b/tests/reject-format
+@@ -79,7 +79,7 @@ check 'cat f.rej' <<EOF
+ Index: f
+ --- f.orig
+ +++ f
+-@@ -2,6 +2,6 @@
++@@ -2,6 +2,6 @@ a() {
+  2
+  3
+  $preserve_trailing_blank
+@@ -102,7 +102,7 @@ EOF
+ check 'cat f.rej' <<EOF
+ --- f.orig
+ +++ f
+-@@ -2,6 +2,6 @@
++@@ -2,6 +2,6 @@ a() {
+  2
+  3
+  $preserve_trailing_blank
+diff --git a/tests/remove-directories b/tests/remove-directories
+new file mode 100644
+index 0000000..6acdc49
+--- /dev/null
++++ b/tests/remove-directories
+@@ -0,0 +1,29 @@
++# Copyright (C) 2013 Free Software Foundation, Inc.
++#
++# Copying and distribution of this file, with or without modification,
++# in any medium, are permitted without royalty provided the copyright
++# notice and this notice are preserved.
++
++. $srcdir/test-lib.sh
++
++require_cat
++use_local_patch
++use_tmpdir
++
++# ==============================================================
++# Remove empty parent diectories when removing a file
++
++mkdir dir
++echo foobar > dir/file
++cat > apatch <<EOF
++--- dir/file
+++++ /dev/null
++@@ -1 +0,0 @@
++-foobar
++EOF
++
++check 'patch -p0 -E < apatch' <<EOF
++patching file dir/file
++EOF
++
++ncheck '! test -e dir'
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list