libsecret: retrieve empty password

Since 0ce02e2f (credential/libsecret: store new attributes, 2023-06-16) a test that stores empty username and password fails when t0303-credential-external.sh is run with GIT_TEST_CREDENTIAL_HELPER=libsecret. Retrieve empty password carefully. This fixes test: ok 14 - helper (libsecret) can store empty username Signed-off-by: M Hickford <mirth.hickford@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

M Hickford committed Feb 19, 2024 at 20:40 UTC 8f1f2023b758179b31188b665496b514dbb952d6
1 file changed +3
contrib/credential/libsecret/git-credential-libsecret.c
+3
@@ -164,6 +164,9 @@ static int keyring_get(struct credential *c)
164 if (g_strv_length(parts) >= 1) {
165 g_free(c->password);
166 c->password = g_strdup(parts[0]);
167 + } else {
168 + g_free(c->password);
169 + c->password = g_strdup("");
170 }
171 for (int i = 1; i < g_strv_length(parts); i++) {
172 if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {