Skip to content

Commit 34122b5

Browse files
jnarebgitster
authored andcommitted
gitweb: Always use three argument form of open
From 94638fb6edf3ea693228c680a6a30271ccd77522 Mon Sep 17 00:00:00 2001 From: Jakub Narebski <[email protected]> Date: Mon, 11 May 2009 03:25:55 +0200 Subject: [PATCH] gitweb: Localize magic variable $/ Instead of undefining and then restoring magic variable $/ (input record separator) for 'slurp mode', localize it. While at it, state explicitely that "local $/;" makes it undefined, by using explicit "local $/ = undef;". Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dff2b6d commit 34122b5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

gitweb/gitweb.perl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ sub git_get_link_target {
33253325
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
33263326
or return;
33273327
{
3328-
local $/;
3328+
local $/ = undef;
33293329
$link_target = <$fd>;
33303330
}
33313331
close $fd
@@ -4800,11 +4800,10 @@ sub git_blob_plain {
48004800
-content_disposition =>
48014801
($sandbox ? 'attachment' : 'inline')
48024802
. '; filename="' . $save_as . '"');
4803-
undef $/;
4803+
local $/ = undef;
48044804
binmode STDOUT, ':raw';
48054805
print <$fd>;
48064806
binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
4807-
$/ = "\n";
48084807
close $fd;
48094808
}
48104809

@@ -4906,12 +4905,16 @@ sub git_tree {
49064905
}
49074906
}
49084907
die_error(404, "No such tree") unless defined($hash);
4909-
$/ = "\0";
4910-
open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
4911-
or die_error(500, "Open git-ls-tree failed");
4912-
my @entries = map { chomp; $_ } <$fd>;
4913-
close $fd or die_error(404, "Reading tree failed");
4914-
$/ = "\n";
4908+
4909+
my @entries = ();
4910+
{
4911+
local $/ = "\0";
4912+
open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
4913+
or die_error(500, "Open git-ls-tree failed");
4914+
@entries = map { chomp; $_ } <$fd>;
4915+
close $fd
4916+
or die_error(404, "Reading tree failed");
4917+
}
49154918

49164919
my $refs = git_get_references();
49174920
my $ref = format_ref_marker($refs, $hash_base);
@@ -5806,7 +5809,7 @@ sub git_search {
58065809

58075810
print "<table class=\"pickaxe search\">\n";
58085811
my $alternate = 1;
5809-
$/ = "\n";
5812+
local $/ = "\n";
58105813
open my $fd, '-|', git_cmd(), '--no-pager', 'log', @diff_opts,
58115814
'--pretty=format:%H', '--no-abbrev', '--raw', "-S$searchtext",
58125815
($search_use_regexp ? '--pickaxe-regex' : ());
@@ -5876,7 +5879,7 @@ sub git_search {
58765879
print "<table class=\"grep_search\">\n";
58775880
my $alternate = 1;
58785881
my $matches = 0;
5879-
$/ = "\n";
5882+
local $/ = "\n";
58805883
open my $fd, "-|", git_cmd(), 'grep', '-n',
58815884
$search_use_regexp ? ('-E', '-i') : '-F',
58825885
$searchtext, $co{'tree'};

0 commit comments

Comments
 (0)