Skip to content

Commit 0700cb2

Browse files
committed
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?"
1 parent fd6042e commit 0700cb2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

cook

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,10 @@ sub wildo_match {
648648
}
649649

650650
sub wildo {
651+
my $fd = shift;
651652
my (%what, $topic, $last_merge_to_next, $in_section, $in_desc);
652653
my $too_recent = '9999-99-99';
653-
while (<>) {
654+
while (<$fd>) {
654655
chomp;
655656

656657
if (/^\[(.*)\]$/) {
@@ -849,18 +850,27 @@ sub doit {
849850

850851
use Getopt::Long;
851852

852-
my $wildo;
853-
my $havedone;
854-
if (!GetOptions("wildo" => \$wildo, "havedone" => \$havedone)) {
853+
my ($wildo, $havedone);
854+
if (!GetOptions("wildo" => \$wildo,
855+
"havedone" => \$havedone)) {
855856
print STDERR "$0 [--wildo|--havedone]\n";
856857
exit 1;
857858
}
858859

859860
if ($wildo) {
861+
my $fd;
860862
if (!@ARGV) {
861-
push @ARGV, "Meta/whats-cooking.txt";
863+
open($fd, "<", "Meta/whats-cooking.txt");
864+
} elsif (@ARGV != 1) {
865+
print STDERR "$0 --wildo [filename|HEAD]\n";
866+
exit 1;
867+
} elsif ($ARGV[0] eq "HEAD") {
868+
open($fd, "-|",
869+
qw(git --git-dir=Meta/.git cat-file -p HEAD:whats-cooking.txt));
870+
} else {
871+
open($fd, "<", $ARGV[0]);
862872
}
863-
wildo();
873+
wildo($fd);
864874
} elsif ($havedone) {
865875
havedone();
866876
} else {

0 commit comments

Comments
 (0)