{"thread":{"id":"13757","subject":"[PATCH] Git.pm: fix return value of config method","startedAt":"2008-06-01T20:34:47Z","lastAt":"2008-06-01T20:34:47Z","messageCount":1,"participants":["Lea Wiemann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"78306","messageId":"1212352487-12022-1-git-send-email-LeWiemann@gmail.com","threadId":"13757","inReplyTo":null,"subject":"[PATCH] Git.pm: fix return value of config method","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-01T20:34:47Z","receivedAt":"2008-06-01T20:34:47Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"If config is called in array context, it is supposed to return all\nvalues set for the given option key.  This works for all cases except\nif there is no value set at all.  In that case, it wrongly returns\n(undef) instead of ().  This fixes the return statement so that it\nreturns undef in scalar context but an empty array in array context.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\nUse the following command to test this:\n\nperl -e 'use Git; $r = Git->repository(\".\"); my @a = $r->config(\"nonexistent\"); print scalar @a;'\n\nThis prints 1 before and 0 after applying this patch.\n\nThis will also be covered by the Git.pm test suite, which I'm\ncorrectly working on.\n\n perl/Git.pm |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 07b92c7..222fdbf 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -565,7 +565,7 @@ sub config {\n \t\tmy $E = shift;\n \t\tif ($E->value() == 1) {\n \t\t\t# Key not found.\n-\t\t\treturn undef;\n+\t\t\treturn;\n \t\t} else {\n \t\t\tthrow $E;\n \t\t}\n-- \n1.5.5.GIT\n"}]}