git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
CJChristian Jaeger <christian@jaeger.mine.nu>
Date
Nov 20, 2008, 12:41 UTC
Message-ID
<38041638267157ade226b396cbd960890bc4efd3.1227185278.git.christian@jaeger.mine.nu>

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(-)
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
Message 1 of 1 in “perl/: fix optional argument handling in _load methods”
  1. perl/: fix optional argument handling in _load methodsChristian Jaeger, Nov 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.