From 3bc154df899e4d98bd4ab94e6ca29bc598a1a87b Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Mon, 24 Aug 2009 18:49:29 -0700 Subject: [PATCH] Allow patch to come in on stdin. --- commit-patch | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/commit-patch b/commit-patch index ffe48b8..5f2fe11 100755 --- a/commit-patch +++ b/commit-patch @@ -120,9 +120,18 @@ GetOptions("h|help" => sub { pod2usage(1) }, "F|message-file=s" => \$message_filename) : # commit-partial (), - ) and (scalar @ARGV == 1 || $commit_partial) or pod2usage(2); + ) and ($commit_patch && scalar @ARGV <= 1 || + $commit_partial && scalar @ARGV == 0) or pod2usage(2); + my $patch; -$patch = shift if $commit_patch; +if ($commit_patch) { + if (scalar @ARGV == 1) { + $patch = shift; + } else { + (my $p, $patch) = tempfile("commit-patch-patch-XXXXXXXX", UNLINK=>0); + print $p $_ while (<>); + } +} my $vc_commit = $amend ? ($vc{amend} || die "$vc{name} does not support amending.\n") : $vc{commit}; @@ -219,7 +228,7 @@ commit-patch - commit patches to I, I, I, I, or I I] [B<-F> I] [B<-v>] [B<-n>] I +commit-patch [B<-m> I] [B<-F> I] [B<-v>] [B<-n>] [I] commit-partial [B<-v>] [B<-n>] [I ...] @@ -229,7 +238,8 @@ Normally version control systems don't allow fine grained commits. B allows the user to control I what gets committed (or "recorded", in I parlance) by letting the user supply a patch to be committed rather than using the files in the -current working directory. +current working directory. If I is not supplied on the +command line then the patch will be read from standard input. B is like commit-patch except that it will create a patch from the current changes in the current working directory and -- 2.51.2