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?"
Junio C Hamano committed
Jan 22, 2013 at 14:40 UTC
0700cb225c484bdd886a98543ed16cb0704b3efa
1 file changed
+16
-6
cook
+16
-6
@@ -648,9 +648,10 @@ sub wildo_match {
648
}
649
650
sub wildo {
651
+ my $fd = shift;
652
my (%what, $topic, $last_merge_to_next, $in_section, $in_desc);
653
my $too_recent = '9999-99-99';
653
- while (<>) {
654
+ while (<$fd>) {
655
chomp;
656
657
if (/^\[(.*)\]$/) {
@@ -849,18 +850,27 @@ sub doit {
850
851
use Getopt::Long;
852
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)) {
856
print STDERR "$0 [--wildo|--havedone]\n";
857
exit 1;
858
}
859
860
if ($wildo) {
861
+ my $fd;
862
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]);
872
}
863
- wildo();
873
+ wildo($fd);
874
} elsif ($havedone) {
875
havedone();
876
} else {