]> git.ipfire.org Git - thirdparty/git.git/blobdiff - credential.c
credential: avoid erasing distinct password
[thirdparty/git.git] / credential.c
index 023b59d5711cf2fede0aa0408b47a1a6f64df059..8825c6f132018c8527563c4ca0f1a1ea747b92e0 100644 (file)
@@ -33,13 +33,14 @@ void credential_clear(struct credential *c)
 }
 
 int credential_match(const struct credential *want,
-                    const struct credential *have)
+                    const struct credential *have, int match_password)
 {
 #define CHECK(x) (!want->x || (have->x && !strcmp(want->x, have->x)))
        return CHECK(protocol) &&
               CHECK(host) &&
               CHECK(path) &&
-              CHECK(username);
+              CHECK(username) &&
+              (!match_password || CHECK(password));
 #undef CHECK
 }
 
@@ -102,7 +103,7 @@ static int match_partial_url(const char *url, void *cb)
                warning(_("skipping credential lookup for key: credential.%s"),
                        url);
        else
-               matches = credential_match(&want, c);
+               matches = credential_match(&want, c, 0);
        credential_clear(&want);
 
        return matches;