From 0700cb225c484bdd886a98543ed16cb0704b3efa Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 22 Jan 2013 14:40:54 -0800 Subject: [PATCH] Meta/cook: introduce -w HEAD as an ugly short-hand This should not grok an arbitrary object name as "cook -w $name" is supposed to be getting a filename, but it is handy to say "cook -w HEAD" and get "git cat-file -p HEAD:whats-cooking.txt | cook -w -", i.e. "which topics did I publicly threaten the list to merge soon?" --- cook | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cook b/cook index 8cbc474c9b..f0ccda0808 100755 --- a/cook +++ b/cook @@ -648,9 +648,10 @@ sub wildo_match { } sub wildo { + my $fd = shift; my (%what, $topic, $last_merge_to_next, $in_section, $in_desc); my $too_recent = '9999-99-99'; - while (<>) { + while (<$fd>) { chomp; if (/^\[(.*)\]$/) { @@ -849,18 +850,27 @@ sub doit { use Getopt::Long; -my $wildo; -my $havedone; -if (!GetOptions("wildo" => \$wildo, "havedone" => \$havedone)) { +my ($wildo, $havedone); +if (!GetOptions("wildo" => \$wildo, + "havedone" => \$havedone)) { print STDERR "$0 [--wildo|--havedone]\n"; exit 1; } if ($wildo) { + my $fd; if (!@ARGV) { - push @ARGV, "Meta/whats-cooking.txt"; + open($fd, "<", "Meta/whats-cooking.txt"); + } elsif (@ARGV != 1) { + print STDERR "$0 --wildo [filename|HEAD]\n"; + exit 1; + } elsif ($ARGV[0] eq "HEAD") { + open($fd, "-|", + qw(git --git-dir=Meta/.git cat-file -p HEAD:whats-cooking.txt)); + } else { + open($fd, "<", $ARGV[0]); } - wildo(); + wildo($fd); } elsif ($havedone) { havedone(); } else { -- 2.11.4.GIT