Thread (4 messages) flat view 4 messages, 2 authors, 2016-06-15
STALE3727d

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

From: Dan Zwell <hidden>
Date: 2016-06-15 22:43:51
Subsystem: the rest · Maintainer: Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help