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

[PATCH] Git.pm: Don't return 'undef' in vector context.

From
DZDan Zwell <dzwell@gmail.com>
Date
Nov 16, 2007, 06:15 UTC
Message-ID
<473D3593.9080806@zwell.net>

Previously, the Git->repository()->config('non-existent.key') evaluated to as true in a vector context. Return an empty list instead. --- I don't know whether this breaks anything, because I don't use most of the git perl scripts. I can't imagine that there is a script that relies on the fact that config('non-existent.key') actually returns (''), in an array context. Is this a reasonable change?

  perl/Git.pm |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index e9dc706..ffcc541 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -508,7 +508,7 @@ sub config {
  		my $E = shift;
  		if ($E->value() == 1) {
  			# Key not found.
-			return undef;
+			return wantarray ? () : undef;
  		} else {
  			throw $E;
  		}
-- 
1.5.3.5.565.gf0b83-dirty
Next: Junio C Hamano
Message 1 of 8 in “Git.pm: Don't return 'undef' in vector context.”
  1. Git.pm: Don't return 'undef' in vector context.Dan Zwell, Nov 16, 2007
  2. Junio C HamanoNov 16, 2007
  3. Dan ZwellNov 16, 2007
  4. Junio C HamanoNov 17, 2007
  5. Sebastian HarlNov 16, 2007
  6. Jakub NarebskiNov 16, 2007
  7. Dan ZwellNov 17, 2007
  8. Jakub NarebskiNov 17, 2007

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.