gitweb: Always use three argument form of open

From 94638fb6edf3ea693228c680a6a30271ccd77522 Mon Sep 17 00:00:00 2001
From: Jakub Narebski <jnareb@gmail.com>
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 <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jakub Narebski 2009-05-11 03:29:40 +02:00 committed by Junio C Hamano
parent dff2b6d484
commit 34122b57ec

View File

@ -3325,7 +3325,7 @@ sub git_get_link_target {
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
or return; or return;
{ {
local $/; local $/ = undef;
$link_target = <$fd>; $link_target = <$fd>;
} }
close $fd close $fd
@ -4800,11 +4800,10 @@ sub git_blob_plain {
-content_disposition => -content_disposition =>
($sandbox ? 'attachment' : 'inline') ($sandbox ? 'attachment' : 'inline')
. '; filename="' . $save_as . '"'); . '; filename="' . $save_as . '"');
undef $/; local $/ = undef;
binmode STDOUT, ':raw'; binmode STDOUT, ':raw';
print <$fd>; print <$fd>;
binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
$/ = "\n";
close $fd; close $fd;
} }
@ -4906,12 +4905,16 @@ sub git_tree {
} }
} }
die_error(404, "No such tree") unless defined($hash); die_error(404, "No such tree") unless defined($hash);
$/ = "\0";
my @entries = ();
{
local $/ = "\0";
open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
or die_error(500, "Open git-ls-tree failed"); or die_error(500, "Open git-ls-tree failed");
my @entries = map { chomp; $_ } <$fd>; @entries = map { chomp; $_ } <$fd>;
close $fd or die_error(404, "Reading tree failed"); close $fd
$/ = "\n"; or die_error(404, "Reading tree failed");
}
my $refs = git_get_references(); my $refs = git_get_references();
my $ref = format_ref_marker($refs, $hash_base); my $ref = format_ref_marker($refs, $hash_base);
@ -5806,7 +5809,7 @@ sub git_search {
print "<table class=\"pickaxe search\">\n"; print "<table class=\"pickaxe search\">\n";
my $alternate = 1; my $alternate = 1;
$/ = "\n"; local $/ = "\n";
open my $fd, '-|', git_cmd(), '--no-pager', 'log', @diff_opts, open my $fd, '-|', git_cmd(), '--no-pager', 'log', @diff_opts,
'--pretty=format:%H', '--no-abbrev', '--raw', "-S$searchtext", '--pretty=format:%H', '--no-abbrev', '--raw', "-S$searchtext",
($search_use_regexp ? '--pickaxe-regex' : ()); ($search_use_regexp ? '--pickaxe-regex' : ());
@ -5876,7 +5879,7 @@ sub git_search {
print "<table class=\"grep_search\">\n"; print "<table class=\"grep_search\">\n";
my $alternate = 1; my $alternate = 1;
my $matches = 0; my $matches = 0;
$/ = "\n"; local $/ = "\n";
open my $fd, "-|", git_cmd(), 'grep', '-n', open my $fd, "-|", git_cmd(), 'grep', '-n',
$search_use_regexp ? ('-E', '-i') : '-F', $search_use_regexp ? ('-E', '-i') : '-F',
$searchtext, $co{'tree'}; $searchtext, $co{'tree'};