From b26098fc2f76131f4258d800e0892e87f9138331 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 14 Oct 2016 00:27:53 +0000 Subject: git-svn: reduce scope of input record separator change Reducing the scope of where we change the record separator ($/) avoids bugs in calls which rely on the input record separator further down, such as the 'chomp' usage in command_oneline. This is necessary for a future change to git-svn, but exists in Git.pm since it seems useful for gitweb and our other Perl scripts, too. Signed-off-by: Eric Wong --- perl/Git.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'perl/Git.pm') diff --git a/perl/Git.pm b/perl/Git.pm index ce7e4e8da3..d2c5a8d238 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -59,7 +59,7 @@ require Exporter; command_bidi_pipe command_close_bidi_pipe version exec_path html_path hash_object git_cmd_try remote_refs prompt - get_tz_offset + get_tz_offset get_record credential credential_read credential_write temp_acquire temp_is_locked temp_release temp_reset temp_path); @@ -538,6 +538,20 @@ sub get_tz_offset { return sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]); } +=item get_record ( FILEHANDLE, INPUT_RECORD_SEPARATOR ) + +Read one record from FILEHANDLE delimited by INPUT_RECORD_SEPARATOR, +removing any trailing INPUT_RECORD_SEPARATOR. + +=cut + +sub get_record { + my ($fh, $rs) = @_; + local $/ = $rs; + my $rec = <$fh>; + chomp $rec if defined $rs; + $rec; +} =item prompt ( PROMPT , ISPASSWORD ) -- cgit v1.2.3