@matheusbsbs / matheus-bagliano / commits / 0881d2d130
Fork 0

gitweb: Cleanup - chomp @lines in consistent style

Use 'my @lines = map { chomp; $_ } <$fd>;' form to read all lines of git command output into array without trailing newlines. It has advantage over 'chomp (my (@lines) = <$fd>);' in that it does not modify array. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Jul 30, 2006 at 14:58 UTC 0881d2d1303a067a02e3811d43a1aed04a47945e
1 file changed +9 -10
gitweb/gitweb.cgi
+9 -10
@@ -1064,7 +1064,7 @@ sub git_summary {
1064 "</table>\n";
1065 open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_read_head($project)
1066 or die_error(undef, "Open git-rev-list failed.");
1067 - my (@revlist) = map { chomp; $_ } <$fd>;
1067 + my @revlist = map { chomp; $_ } <$fd>;
1068 close $fd;
1069 print "<div>\n" .
1070 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog"), -class => "title"}, "shortlog") .
@@ -1709,7 +1709,7 @@ sub git_tree {
1709 $/ = "\0";
1710 open my $fd, "-|", $GIT, "ls-tree", '-z', $hash
1711 or die_error(undef, "Open git-ls-tree failed.");
1712 - chomp (my (@entries) = <$fd>);
1712 + my @entries = map { chomp; $_ } <$fd>;
1713 close $fd or die_error(undef, "Reading tree failed.");
1714 $/ = "\n";
1715
@@ -1791,7 +1791,7 @@ 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)
1793 or die_error(undef, "Open git-rev-list failed.");
1794 - my (@revlist) = map { chomp; $_ } <$fd>;
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');
1797 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
@@ -1900,7 +1900,7 @@ sub git_log {
1900 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
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>;
1903 + my @revlist = map { chomp; $_ } <$fd>;
1904 close $fd;
1905
1906 if ($hash ne $head || $page) {
@@ -1983,14 +1983,13 @@ sub git_commit {
1983 my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1984 my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
1985
1986 - my @difftree;
1986 my $parent = $co{'parent'};
1987 if (!defined $parent) {
1988 $parent = "--root";
1989 }
1990 open my $fd, "-|", $GIT, "diff-tree", '-r', '-M', $parent, $hash
1991 or die_error(undef, "Open git-diff-tree failed.");
1993 - @difftree = map { chomp; $_ } <$fd>;
1992 + my @difftree = map { chomp; $_ } <$fd>;
1993 close $fd or die_error(undef, "Reading git-diff-tree failed.");
1994
1995 # non-textual hash id's can be cached
@@ -2237,7 +2236,7 @@ sub git_commitdiff {
2236 }
2237 open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
2238 or die_error(undef, "Open git-diff-tree failed.");
2240 - my (@difftree) = map { chomp; $_ } <$fd>;
2239 + my @difftree = map { chomp; $_ } <$fd>;
2240 close $fd or die_error(undef, "Reading diff-tree failed.");
2241
2242 # non-textual hash id's can be cached
@@ -2328,14 +2327,14 @@ sub git_commitdiff_plain {
2327 mkdir($git_temp, 0700);
2328 open my $fd, "-|", $GIT, "diff-tree", '-r', $hash_parent, $hash
2329 or die_error(undef, "Open git-diff-tree failed.");
2331 - my (@difftree) = map { chomp; $_ } <$fd>;
2330 + my @difftree = map { chomp; $_ } <$fd>;
2331 close $fd or die_error(undef, "Reading diff-tree failed.");
2332
2333 # try to figure out the next tag after this commit
2334 my $tagname;
2335 my $refs = read_info_ref("tags");
2336 open $fd, "-|", $GIT, "rev-list", "HEAD";
2338 - chomp (my (@commits) = <$fd>);
2337 + my @commits = map { chomp; $_ } <$fd>;
2338 close $fd;
2339 foreach my $commit (@commits) {
2340 if (defined $refs->{$commit}) {
@@ -2622,7 +2621,7 @@ sub git_shortlog {
2621 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2622 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
2623 or die_error(undef, "Open git-rev-list failed.");
2625 - my (@revlist) = map { chomp; $_ } <$fd>;
2624 + my @revlist = map { chomp; $_ } <$fd>;
2625 close $fd;
2626
2627 if ($hash ne $head || $page) {