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 <e@80x24.org>
This commit is contained in:
Eric Wong
2016-10-14 00:27:53 +00:00
parent 3cdd5d1917
commit b26098fc2f
4 changed files with 27 additions and 20 deletions

View File

@ -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 )