]> git.ipfire.org Git - thirdparty/git.git/commitdiff
netrc: ignore unknown lines (do not die)
authorMatthew John Cheetham <mjcheetham@outlook.com>
Thu, 22 Sep 2022 16:59:33 +0000 (16:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Sep 2022 21:20:59 +0000 (14:20 -0700)
Contrary to the documentation on credential helpers, as well as the help
text for git-credential-netrc itself, this helper will `die` when
presented with an unknown property/attribute/token.

Correct the behaviour here by skipping and ignoring any tokens that are
unknown. This means all helpers in the tree are consistent and ignore
any unknown credential properties/attributes.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/credential/netrc/git-credential-netrc.perl

index bc57cc65884b97dc6a0d33a067f00dac35ee19a8..9fb998ae090325ba0e0080d31798b7b01870b30e 100755 (executable)
@@ -356,7 +356,10 @@ sub read_credential_data_from_stdin {
                next unless m/^([^=]+)=(.+)/;
 
                my ($token, $value) = ($1, $2);
-               die "Unknown search token $token" unless exists $q{$token};
+
+               # skip any unknown tokens
+               next unless exists $q{$token};
+
                $q{$token} = $value;
                log_debug("We were given search token $token and value $value");
        }