Kaynağa Gözat

git-notify: Check the exit status of pipes

Properly check the exit status of all processes we execute and abort on
error.
Holger Weiss 16 yıl önce
ebeveyn
işleme
61f2cebae3
1 değiştirilmiş dosya ile 5 ekleme ve 5 silme
  1. 5 5
      tools/git-notify

+ 5 - 5
tools/git-notify

@@ -309,7 +309,7 @@ sub mail_notification($$$@)
         }
         }
         binmode MAIL, ":utf8";
         binmode MAIL, ":utf8";
         print MAIL join("\n", @text), "\n";
         print MAIL join("\n", @text), "\n";
-        close MAIL;
+        close MAIL or die $! ? "Cannot execute $mailer: $!" : "$mailer exited with status: $?";
     }
     }
 }
 }
 
 
@@ -350,7 +350,7 @@ sub get_object_info($)
             $info{$1 . "_tz"} = $6;
             $info{$1 . "_tz"} = $6;
         }
         }
     }
     }
-    close OBJ;
+    close OBJ or die $! ? "Cannot execute cat-file: $!" : "cat-file exited with status: $?";
 
 
     $info{"log"} = \@log;
     $info{"log"} = \@log;
     return %info;
     return %info;
@@ -388,7 +388,7 @@ sub send_commit_notice($$)
 
 
     open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
     open DIFF, "-|" or exec "git", "diff-tree", "-p", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
     my $diff = join("", <DIFF>);
     my $diff = join("", <DIFF>);
-    close DIFF;
+    close DIFF or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
 
 
     return if length($diff) == 0;
     return if length($diff) == 0;
 
 
@@ -419,7 +419,7 @@ sub send_commit_notice($$)
 
 
     open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
     open STAT, "-|" or exec "git", "diff-tree", "--stat", "-M", "--no-commit-id", $obj or die "cannot exec git-diff-tree";
     push @notice, join("", <STAT>);
     push @notice, join("", <STAT>);
-    close STAT;
+    close STAT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
 
 
     if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
     if (($max_diff_size == -1) || (length($diff) < $max_diff_size))
     {
     {
@@ -479,7 +479,7 @@ sub send_cia_notice($$)
             push @cia_text, "        <file action=\"rename\" to=\"" . xml_escape($new) . "\">" . xml_escape($old) . "</file>";
             push @cia_text, "        <file action=\"rename\" to=\"" . xml_escape($new) . "\">" . xml_escape($old) . "</file>";
         }
         }
     }
     }
-    close COMMIT;
+    close COMMIT or die $! ? "Cannot execute diff-tree: $!" : "diff-tree exited with status: $?";
 
 
     push @cia_text,
     push @cia_text,
         "      </files>",
         "      </files>",