Skip Menu |

This queue is for tickets about the makepatch CPAN distribution.

Report information
The Basics
Id: 80266
Status: resolved
Priority: 0/
Queue: makepatch

People
Owner: jv [...] cpan.org
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.04
Fixed in: 2.05



Subject: patch fails if there's no patch, just file removal
If the makepatch generated patch does not actually patch anything, but simply removes files, the patch data is empty. applypatch still passes it to the patch command, which fails with (on Linux) with

/usr/bin/patch: **** Only garbage was found in the patch input.
Possible problems with "patch -p0 -N -s", status = 512.

and applypatch exits with error. 

I've attached a tar file with example orig and new directories , and a patch, new.patch, that goes from orig to new

I've attached a patch which only invokes the patch command if there's actual patch data.

Diab

Subject: makepatch-2.04.patch
# This is a patch for makepatch-2.04.orig to update it to makepatch-2.04 # # To apply this patch: # STEP 1: Chdir to the source directory. # STEP 2: Run the 'applypatch' program with this patch file as input. # # If you do not have 'applypatch', it is part of the 'makepatch' package # that you can fetch from the Comprehensive Perl Archive Network: # http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz # In the above URL, 'x' should be 2 or higher. # # To apply this patch without the use of 'applypatch': # STEP 1: Chdir to the source directory. # STEP 2: Run the 'patch' program with this file as input. # #### End of Preamble #### #### Patch data follows #### diff -c 'makepatch-2.04.orig/script/applypatch' 'makepatch-2.04/script/applypatch' Index: ./script/applypatch Prereq: 1.20 *** ./script/applypatch Sun Oct 8 09:07:07 2006 --- ./script/applypatch Thu Oct 18 13:47:09 2012 *************** *** 377,402 **** } sub execute_patch () { ! my $p = new IO::File; print STDERR ("+ $patch\n") if $trace; - $p->open("|$patch") || die ("Cannot open pipe to \"$patch\": $!\n"); - binmode($p); if ( $applypatch ) { my $lines = 0; while ( <$tmpfile> ) { chomp; - $lines++; print STDERR ("++ ", $_, "\n") if $debug; ! print $p ($_, "\n"); last if $_ eq "#### End of Patch data ####"; } print STDERR ("+ $lines lines sent to \"$patch\"\n") if $trace; } else { ! print $p ($_) while <$tmpfile>; } ! $p->close || die ("Possible problems with \"$patch\", status = $?.\n"); } sub set_utime ($$;$) { --- 377,419 ---- } + + sub _open_patch () { + + my $p = new IO::File; + $p->open("|$patch") || die ("Cannot open pipe to \"$patch\": $!\n"); + binmode($p); + + return $p + } + + sub execute_patch () { ! ! my $p; ! print STDERR ("+ $patch\n") if $trace; if ( $applypatch ) { my $lines = 0; while ( <$tmpfile> ) { chomp; print STDERR ("++ ", $_, "\n") if $debug; ! next if $_ eq "#### Patch data follows ####"; last if $_ eq "#### End of Patch data ####"; + $p = _open_patch() unless $p; + print $p ($_, "\n"); + $lines++; } print STDERR ("+ $lines lines sent to \"$patch\"\n") if $trace; } else { ! while ( <$tmpfile> ) { ! $p = _open_patch() unless $p; ! print $p ($_) ! } } ! defined $p and ! $p->close || die ("Possible problems with \"$patch\", status = $?.\n"); } sub set_utime ($$;$) { #### End of Patch data #### #### ApplyPatch data follows #### # Data version : 1.0 # Date generated : Thu Oct 18 13:48:22 2012 # Generated by : makepatch 2.04 # Recurse directories : Yes # Excluded files : (\A|/).*\~\Z # (\A|/).*\.a\Z # (\A|/).*\.bak\Z # (\A|/).*\.BAK\Z # (\A|/).*\.elc\Z # (\A|/).*\.exe\Z # (\A|/).*\.gz\Z # (\A|/).*\.ln\Z # (\A|/).*\.o\Z # (\A|/).*\.obj\Z # (\A|/).*\.olb\Z # (\A|/).*\.old\Z # (\A|/).*\.orig\Z # (\A|/).*\.rej\Z # (\A|/).*\.so\Z # (\A|/).*\.Z\Z # (\A|/)\.del\-.*\Z # (\A|/)\.make\.state\Z # (\A|/)\.nse_depinfo\Z # (\A|/)core\Z # (\A|/)tags\Z # (\A|/)TAGS\Z # p 'script/applypatch' 17302 1350582429 0100555 #### End of ApplyPatch data #### #### End of Patch kit [created: Thu Oct 18 13:48:22 2012] #### #### Patch checksum: 111 3120 852 #### #### Checksum: 129 3813 58374 ####
Subject: example.tar
Download example.tar
application/x-tar 10k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #80266] patch fails if there's no patch, just file removal
Date: Fri, 26 Oct 2012 21:58:01 +0200
To: bug-makepatch [...] rt.cpan.org
From: Johan Vromans <jvromans [...] squirrel.nl>
[Quoting Diab Jerius via RT, on October 18 2012, 13:52, in "[rt.cpan.org #80266]"] Show quoted text
> I've attached a patch which only invokes the patch command if > there's actual patch data.
Thanks, applied. 2.05 is on its way to CPAN. -- Johan