chiark / gitweb /
rename TODO -> BUGS for better completion
[topbloke.git] / Topbloke.pm
index 56055cf688bb42dc3a007c5603c7c2499b3b3fad..b6de69022bd325306cdc6109394888c3507bebf6 100644 (file)
@@ -17,13 +17,15 @@ BEGIN {
     @ISA         = qw(Exporter);
     @EXPORT      = qw(debug
                      run_git run_git_1line run_git_check_nooutput
-                     run_git_test_anyoutput
+                     run_git_test_anyoutput git_get_object
                      git_config git_dir chdir_toplevel
-                     current_branch parse_patch_spec
+                     current_branch parse_patch_spec parse_patch_name
                      setup_config check_no_unwanted_metadata
+                     patch_matches_spec
                      foreach_patch
                      flagsfile_add_flag
-                     wf_start wf wf_abort wf_done wf_contents);
+                     wf_start wf wf_abort wf_done wf_contents
+                     closeout);
     %EXPORT_TAGS = ( );
     @EXPORT_OK   = qw();
 }
@@ -97,17 +99,24 @@ sub git_get_object ($) {
                                     $git_command, qw(cat-file --batch))
            or die $!;
     }
+    #debug("git_get_object $objname");
     $SIG{'PIPE'} = 'IGN';
     print $gro_in $objname,"\n" or die $!;
     $gro_in->flush or die "$objname $!";
     $SIG{'PIPE'} = 'DFL';
     my $l = <$gro_out>;
     chomp $l or die "$objname $l ?";
+    #debug("git_get_object $objname => $l");
     if ($l =~ m/ missing$/) {
        return 'missing';
     } elsif (my ($type,$bytes) = $l =~ m/^\S+ (\w+) (\d+)$/) {
-       my $data;
-       read $gro_out, $data, $bytes == $bytes or die "$objname $!";
+       my $data = '';
+       if ($bytes) {
+           (read $gro_out, $data, $bytes) == $bytes or die "$objname $!";
+       }
+       my $nl;
+       (read $gro_out, $nl, 1) == 1 or die "$objname $!";
+       $nl eq "\n" or die "$objname ?";
        return ($type, $data);
     } else {
        die "$objname $l";
@@ -158,6 +167,7 @@ sub current_branch () {
        };
     }
     if ($ref =~ m#^refs/topbloke-(tip|base)s/([^/\@]*)\@([^/\@]*)/([^/]*)/#) {
+       my $fullname = "$2\@$3/$4/$'";
        return {
            Kind => $1,
            Email => $2,
@@ -165,7 +175,8 @@ sub current_branch () {
            Date => $4,
            Nick => $', #',
            Ref => $ref,
-           DepSpec => "$2\@$3/$4/$'",
+           DepSpec => $fullname,
+           Fullname => $fullname,
        };
     } elsif ($ref =~ m#^refs/heads/#) {
        return {
@@ -192,6 +203,10 @@ sub parse_patch_name ($) {
        Domain => $domain,
        Date => $date,
        Nick => $nick,
+       Kind => 'tip',
+       DepSpec => $patch,
+       Fullname => $patch,
+       Ref => "refs/topbloke-tips/$patch",
     };
 }
 
@@ -427,4 +442,9 @@ sub wf_contents ($$) {
     wf_done($wf);
 }
 
+sub closeout () {
+    STDOUT->error and die $!;
+    close STDOUT or die $!;
+}
+
 1;