mw-to-git: check blank credential attributes via length
authorJeff King <peff@peff.net>
Wed, 18 Jul 2012 12:04:30 +0000 (08:04 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Jul 2012 20:26:53 +0000 (13:26 -0700)
When writing a credential to git-credential, we omit fields
that do not have a true value. This will skip empty or
undefined fields (which we want), but will also accidentally
skip usernames or passwords which happen to have a non-true
value (e.g., "0"). Be more careful by checking for non-zero
length.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/mw-to-git/git-remote-mediawiki

index accd70a94c82b425039b55afdf7b4b8761e7faba..b06f27b9211567a96b9ffb9135e26ce56373622e 100755 (executable)
@@ -207,7 +207,7 @@ sub credential_write {
        my $credential = shift;
        my $writer = shift;
        while (my ($key, $value) = each(%$credential) ) {
-               if ($value) {
+               if (length $value) {
                        print $writer "$key=$value\n";
                }
        }