threads / patch / 16410

patchperl/: fix optional argument handling in _load methods

Subject: [PATCH/gitweb-caching] perl/: fix optional argument handling in _load methods

## tl;dr

One message between Nov 20, 2008 and Nov 20, 2008. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Christian Jaeger· Nov 20, 2008, 12:41 UTC · lore

Perl's 'shift' only ever delivers the first of all subroutine/method arguments, meaning that $self would be assigned a value but $raw_text would always remain undef even if an argument would have been passed to the method.

Signed-off-by: Christian Jaeger <christian@jaeger.mine.nu>
---
 This is a fix for the code in git://repo.or.cz/git/gitweb-caching.git
 perl/Git/Commit.pm |    3 ++-
 perl/Git/Tag.pm    |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
Show changes to 2 files +4 −2

perl/Git/Commit.pm, perl/Git/Tag.pm

diff --git a/perl/Git/Commit.pm b/perl/Git/Commit.pm
index ee87e11..6ed076b 100644
--- a/perl/Git/Commit.pm
+++ b/perl/Git/Commit.pm
@@ -141,7 +141,8 @@ sub encoding {
 # The raw contents of the commit object; the commit object will be
 # retrieved from the repository if that parameter is not given.
 sub _load {
-	my ($self, $raw_text) = shift;
+	my $self = shift;
+	my ($raw_text)=@_;
 	return if exists $self->{message};  # already loaded
 
 	my $sha1 = $self->sha1;
diff --git a/perl/Git/Tag.pm b/perl/Git/Tag.pm
index 5622431..e1f1201 100644
--- a/perl/Git/Tag.pm
+++ b/perl/Git/Tag.pm
@@ -132,7 +132,8 @@ sub encoding {
 # The raw contents of the tag object; the tag object will be retrieved
 # from the repository if that parameter is not given.
 sub _load {
-	my ($self, $raw_text) = shift;
+	my $self = shift;
+	my ($raw_text)=@_;
 	return if exists $self->{message};  # already loaded
 
 	my $sha1 = $self->sha1;
-- 
1.6.0.4

← back to recent threads