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

[PATCH] Git.pm: fix return value of config method

From
LWLea Wiemann <lewiemann@gmail.com>
Date
Jun 1, 2008, 20:34 UTC
Message-ID
<1212352487-12022-1-git-send-email-LeWiemann@gmail.com>

If config is called in array context, it is supposed to return all values set for the given option key. This works for all cases except if there is no value set at all. In that case, it wrongly returns (undef) instead of (). This fixes the return statement so that it returns undef in scalar context but an empty array in array context.

Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
---
Use the following command to test this:
perl -e 'use Git; $r = Git->repository("."); my @a = $r->config("nonexistent"); print scalar @a;'
This prints 1 before and 0 after applying this patch.

This will also be covered by the Git.pm test suite, which I'm correctly working on.

 perl/Git.pm |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 07b92c7..222fdbf 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -565,7 +565,7 @@ sub config {
 		my $E = shift;
 		if ($E->value() == 1) {
 			# Key not found.
-			return undef;
+			return;
 		} else {
 			throw $E;
 		}
-- 
1.5.5.GIT
Message 1 of 1 in “Git.pm: fix return value of config method”
  1. Git.pm: fix return value of config methodLea Wiemann, Jun 1, 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.