]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Meta/cook: introduce -w HEAD as an ugly short-hand
authorJunio C Hamano <gitster@pobox.com>
Tue, 22 Jan 2013 22:40:54 +0000 (14:40 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 Jan 2013 22:40:54 +0000 (14:40 -0800)
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

diff --git a/cook b/cook
index 8cbc474c9b56e38702820ff3b93ff2426722d527..f0ccda0808acda0131ec8ae81cc77448413f72fb 100755 (executable)
--- 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 {