@matheusbsbs / matheus-bagliano / commits / 044bfdc8cb
Fork 0

gitweb: More explicit error messages for open "-|"

Use more explicit error messages when failing magical "-|" open, stating at least the name of the git command that failed. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Jul 29, 2006 at 23:01 UTC 044bfdc8cbc4955f20afd7f9a245dfc20527ecbd
1 file changed +17 -12
gitweb/gitweb.cgi
+17 -12
@@ -1063,7 +1063,7 @@ sub git_summary {
1063 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
1064 "</table>\n";
1065 open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_read_head($project)
1066 - or die_error(undef, "Open failed.");
1066 + or die_error(undef, "Open git-rev-list failed.");
1067 my (@revlist) = map { chomp; $_ } <$fd>;
1068 close $fd;
1069 print "<div>\n" .
@@ -1271,7 +1271,7 @@ sub git_blame2 {
1271 die_error("400 Bad Request", "object is not a blob");
1272 }
1273 open ($fd, "-|", $GIT, "blame", '-l', $file_name, $hash_base)
1274 - or die_error(undef, "Open failed");
1274 + or die_error(undef, "Open git-blame failed.");
1275 git_header_html();
1276 print "<div class=\"page_nav\">\n" .
1277 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1333,7 +1333,7 @@ sub git_blame {
1333 or die_error(undef, "Error lookup file.");
1334 }
1335 open ($fd, "-|", $GIT, "annotate", '-l', '-t', '-r', $file_name, $hash_base)
1336 - or die_error(undef, "Open failed.");
1336 + or die_error(undef, "Open git-annotate failed.");
1337 git_header_html();
1338 print "<div class=\"page_nav\">\n" .
1339 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
@@ -1609,7 +1609,8 @@ sub git_blob_plain {
1609 }
1610 }
1611 my $type = shift;
1612 - open my $fd, "-|", $GIT, "cat-file", "blob", $hash or die_error("Couldn't cat $file_name, $hash");
1612 + open my $fd, "-|", $GIT, "cat-file", "blob", $hash
1613 + or die_error("Couldn't cat $file_name, $hash");
1614
1615 $type ||= git_blob_plain_mimetype($fd, $file_name);
1616
@@ -1641,7 +1642,8 @@ sub git_blob {
1642 }
1643 }
1644 my $have_blame = git_get_project_config_bool ('blame');
1644 - open my $fd, "-|", $GIT, "cat-file", "blob", $hash or die_error(undef, "Open failed.");
1645 + open my $fd, "-|", $GIT, "cat-file", "blob", $hash
1646 + or die_error(undef, "Couldn't cat $file_name, $hash.");
1647 my $mimetype = git_blob_plain_mimetype($fd, $file_name);
1648 if ($mimetype !~ m/^text\//) {
1649 close $fd;
@@ -1705,7 +1707,8 @@ sub git_tree {
1707 }
1708 }
1709 $/ = "\0";
1708 - open my $fd, "-|", $GIT, "ls-tree", '-z', $hash or die_error(undef, "Open git-ls-tree failed.");
1710 + open my $fd, "-|", $GIT, "ls-tree", '-z', $hash
1711 + or die_error(undef, "Open git-ls-tree failed.");
1712 chomp (my (@entries) = <$fd>);
1713 close $fd or die_error(undef, "Reading tree failed.");
1714 $/ = "\n";
@@ -1787,7 +1790,7 @@ sub git_tree {
1790 sub git_rss {
1791 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
1792 open my $fd, "-|", $GIT, "rev-list", "--max-count=150", git_read_head($project)
1790 - or die_error(undef, "Open failed.");
1793 + or die_error(undef, "Open git-rev-list failed.");
1794 my (@revlist) = map { chomp; $_ } <$fd>;
1795 close $fd or die_error(undef, "Reading rev-list failed.");
1796 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
@@ -1895,7 +1898,8 @@ sub git_log {
1898 " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
1899
1900 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1898 - open my $fd, "-|", $GIT, "rev-list", $limit, $hash or die_error(undef, "Open failed.");
1901 + open my $fd, "-|", $GIT, "rev-list", $limit, $hash
1902 + or die_error(undef, "Open git-rev-list failed.");
1903 my (@revlist) = map { chomp; $_ } <$fd>;
1904 close $fd;
1905
@@ -1985,7 +1989,7 @@ sub git_commit {
1989 $parent = "--root";
1990 }
1991 open my $fd, "-|", $GIT, "diff-tree", '-r', '-M', $parent, $hash
1988 - or die_error(undef, "Open failed.");
1992 + or die_error(undef, "Open git-diff-tree failed.");
1993 @difftree = map { chomp; $_ } <$fd>;
1994 close $fd or die_error(undef, "Reading git-diff-tree failed.");
1995
@@ -2232,7 +2236,7 @@ sub git_commitdiff {
2236 $hash_parent = $co{'parent'};
2237 }
2238 open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
2235 - or die_error(undef, "Open failed.");
2239 + or die_error(undef, "Open git-diff-tree failed.");
2240 my (@difftree) = map { chomp; $_ } <$fd>;
2241 close $fd or die_error(undef, "Reading diff-tree failed.");
2242
@@ -2323,7 +2327,7 @@ sub git_commitdiff {
2327 sub git_commitdiff_plain {
2328 mkdir($git_temp, 0700);
2329 open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
2326 - or die_error(undef, "Open failed.");
2330 + or die_error(undef, "Open git-diff-tree failed.");
2331 my (@difftree) = map { chomp; $_ } <$fd>;
2332 close $fd or die_error(undef, "Reading diff-tree failed.");
2333
@@ -2616,7 +2620,8 @@ sub git_shortlog {
2620 " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
2621
2622 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2619 - open my $fd, "-|", $GIT, "rev-list", $limit, $hash or die_error(undef, "Open failed.");
2623 + open my $fd, "-|", $GIT, "rev-list", $limit, $hash
2624 + or die_error(undef, "Open git-rev-list failed.");
2625 my (@revlist) = map { chomp; $_ } <$fd>;
2626 close $fd;
2627