summaryrefslogtreecommitdiff
path: root/perl/Git.pm
diff options
context:
space:
mode:
authorLibravatar Eric Wong <e@80x24.org>2016-10-14 00:27:53 +0000
committerLibravatar Eric Wong <e@80x24.org>2016-10-14 01:36:05 +0000
commitb26098fc2f76131f4258d800e0892e87f9138331 (patch)
tree5e594a70e499b0b18f02f7ff887fa2b60fed713f /perl/Git.pm
parentSync with maint (diff)
downloadtgif-b26098fc2f76131f4258d800e0892e87f9138331.tar.xz
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>
Diffstat (limited to 'perl/Git.pm')
-rw-r--r--perl/Git.pm16
1 files changed, 15 insertions, 1 deletions
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 )