Skip to content

patch.exe regression: can not handle general patches #51

@zmughal

Description

@zmughal

When trying to apply a patch, patch gives the error:

patch: **** Can't rename file src/secure_allocator.hpp to src/secure_allocator.hpp.orig : No such file or directory

It appears to apply when there is a directory prefix, so for the above, a
workaround is to do -d src -p2 to remove the a/src/ part.


Test case:

Commands:

mkdir C:\b & cd C:\b
curl -OL https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz & curl -OL https://github.com/zeromq/libzmq/pull/4480.patch
tar xzf zeromq-4.3.4.tar.gz & cd zeromq-4.3.4
certUtil -hashfile src\secure_allocator.hpp MD5
patch --binary -p1 -i C:\b\4480.patch
certUtil -hashfile src\secure_allocator.hpp MD5
patch --binary -d src -p2 -i C:\b\4480.patch
certUtil -hashfile src\secure_allocator.hpp MD5
patch --version
where patch.exe

The following is a transcript with StrawberryPerl 5.38.1's patch.exe:

vagrant@VAGRANTVM C:\b>curl -OL https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz & curl -OL https://github.com/zeromq/libzmq/pull/4480.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2428k  100 2428k    0     0  4735k      0 --:--:-- --:--:-- --:--:-- 4735k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3537    0  3537    0     0   5513      0 --:--:-- --:--:-- --:--:-- 15051

vagrant@VAGRANTVM C:\b>tar xzf zeromq-4.3.4.tar.gz & cd zeromq-4.3.4

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
47cd75dd30c5d9a7d4bb6a42df377664
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -p1 -i C:\b\4480.patch
patching file src/secure_allocator.hpp
Hunk StrawberryPerl/Perl-Dist-Strawberry#1 succeeded at 95 (offset -4 lines).
patch: **** Can't rename file src/secure_allocator.hpp to src/secure_allocator.hpp.orig : No such file or directory

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
47cd75dd30c5d9a7d4bb6a42df377664
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -d src -p2 -i C:\b\4480.patch
patching file secure_allocator.hpp
Hunk StrawberryPerl/Perl-Dist-Strawberry#1 succeeded at 95 (offset -4 lines).

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
a616d5049eddb65001856dbbc8f5105c
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --version
GNU patch 2.7.5
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>where patch.exe
C:\Strawberry\c\bin\patch.exe

The following is a transcript with StrawberryPerl 5.32.1.1's patch.exe:

vagrant@VAGRANTVM C:\b>curl -OL https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz & curl -OL https://github.com/zeromq/libzmq/pull/4480.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2428k  100 2428k    0     0  4431k      0 --:--:-- --:--:-- --:--:-- 7833k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  3537    0  3537    0     0   6267      0 --:--:-- --:--:-- --:--:--  6267

vagrant@VAGRANTVM C:\b>tar xzf zeromq-4.3.4.tar.gz & cd zeromq-4.3.4

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
47cd75dd30c5d9a7d4bb6a42df377664
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -p1 -i C:\b\4480.patch
patching file src/secure_allocator.hpp
Hunk StrawberryPerl/Perl-Dist-Strawberry#1 succeeded at 95 (offset -4 lines).

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
a616d5049eddb65001856dbbc8f5105c
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --binary -d src -p2 -i C:\b\4480.patch
patching file secure_allocator.hpp
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file secure_allocator.hpp.rej

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>certUtil -hashfile src\secure_allocator.hpp MD5
MD5 hash of src\secure_allocator.hpp:
a616d5049eddb65001856dbbc8f5105c
CertUtil: -hashfile command completed successfully.

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>patch --version
patch 2.5.9
Copyright (C) 1988 Larry Wall
Copyright (C) 2003 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

written by Larry Wall and Paul Eggert

vagrant@VAGRANTVM C:\b\zeromq-4.3.4>where patch.exe
C:\Strawberry\c\bin\patch.exe

Connects with StrawberryPerl/Perl-Dist-Strawberry#74.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions