diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-11-23 22:51:13 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-11-25 10:56:59 +0100 |
commit | 58a28a53892a910428c7a1315f9dc4ecbf6a9252 (patch) | |
tree | df7d108932c8641e45fc7758999ac802469ef81b /Porting | |
parent | ae5aebe9e8ef2f74e2acd7906088c31604be14a9 (diff) | |
download | perl-58a28a53892a910428c7a1315f9dc4ecbf6a9252.tar.gz |
In bisect-runner.pl, only shell out to patch from apply_patch().
Previously the system's patch binary was invoked from 3 places. Refactoring
the code to only call it from one place will make it easier to work around
ancient versions of patch that some vendors still supply.
Diffstat (limited to 'Porting')
-rwxr-xr-x | Porting/bisect-runner.pl | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/Porting/bisect-runner.pl b/Porting/bisect-runner.pl index 711a14a714..a1e5a02796 100755 --- a/Porting/bisect-runner.pl +++ b/Porting/bisect-runner.pl @@ -531,28 +531,37 @@ sub edit_file { } sub apply_patch { - my $patch = shift; - - my ($file) = $patch =~ qr!^--- a/(\S+)\n\+\+\+ b/\1!sm; + my ($patch, $what, $files) = @_; + $what = 'patch' unless defined $what; + unless (defined $files) { + $patch =~ m!^--- a/(\S+)\n\+\+\+ b/\1!sm; + $files = " $1"; + } open my $fh, '|-', 'patch', '-p1' or die "Can't run patch: $!"; print $fh $patch; return if close $fh; print STDERR "Patch is <<'EOPATCH'\n${patch}EOPATCH\n"; - die "Can't patch $file: $?, $!"; + die "Can't $what$files: $?, $!"; } sub apply_commit { my ($commit, @files) = @_; - return unless system "git show $commit @files | patch -p1"; - die "Can't apply commit $commit to @files" if @files; - die "Can't apply commit $commit"; + my $patch = `git show $commit @files`; + if (!defined $patch) { + die "Can't get commit $commit for @files: $?" if @files; + die "Can't get commit $commit: $?"; + } + apply_patch($patch, "patch $commit", @files ? " for @files" : ''); } sub revert_commit { my ($commit, @files) = @_; - return unless system "git show -R $commit @files | patch -p1"; - die "Can't apply revert $commit from @files" if @files; - die "Can't apply revert $commit"; + my $patch = `git show -R $commit @files`; + if (!defined $patch) { + die "Can't get revert commit $commit for @files: $?" if @files; + die "Can't get revert commit $commit: $?"; + } + apply_patch($patch, "revert $commit", @files ? " for @files" : ''); } sub checkout_file { |