diff --git a/commit-patch b/commit-patch index 18ff603..1b702f8 100755 --- a/commit-patch +++ b/commit-patch @@ -11,9 +11,9 @@ use File::Temp qw(tempfile); use Getopt::Long; use Pod::Usage; -my ($verbose); +my ($dry_run, $verbose); sub run { - if ($verbose) { + if ($verbose || $dry_run) { for (@_) { print join ' ', @$_ if ref $_ eq 'ARRAY'; print " $_ " if ref $_ eq ''; @@ -21,6 +21,7 @@ sub run { } print "\n"; } + return 1 if $dry_run; IPC::Run::run(@_); } @@ -28,6 +29,7 @@ my ($message, $message_filename); GetOptions("message|m=s" => \$message, "F|message-file=s" => \$message_filename, "h|help" => sub { pod2usage(1) }, + "n|dry-run" => \$dry_run, "v|verbose" => \$verbose, ) and scalar @ARGV == 1 or pod2usage(2); my $patch = shift; @@ -113,6 +115,7 @@ eval { run(["patch", $vc{patcharg}], '<', "non_committed.patch.$$", '>', \$out, '2>', \$err) or die "$out\n$err\n"; }; sub clean() { + return if $dry_run; foreach my $k (keys %clean) { rename $k,$clean{$k} if $clean{$k} } } if ($@) { @@ -128,7 +131,7 @@ commit-patch - commit patches to I, I or I repositories =head1 SYNOPSIS -commit-patch [B<-m> I] [B<-F> I] [B<-v>] I +commit-patch [B<-m> I] [B<-F> I] [B<-v>] [B<-n>] I =head1 DESCRIPTION @@ -160,6 +163,10 @@ scripting B. B<-v>, B<--verbose> - Turn on debugging. This will print the commands that B is running to get the patch committed. +B<-n>, B<--dry-run> - Turn on more paranoid debugging. This will print +the commands that B will run to get the patch committed +but it wont actually run those commands. + =head1 DIAGNOSTICS B works by manipulating the working directory using