credential.c: store "wwwauth[]" values in `credential_read()`

Teach git-credential to read "wwwauth[]" value(s) when parsing the
output of a credential helper.

These extra headers are not needed for Git's own HTTP support to use the
feature internally, but the feature would not be available for a
scripted caller (say, git-remote-mediawiki providing the header in the
same way).

As a bonus, this also makes it easier to use wwwauth[] in synthetic
credential inputs in our test suite.

Co-authored-by: Jeff King <>
Signed-off-by: Jeff King <>
Signed-off-by: Taylor Blau <>
Signed-off-by: Junio C Hamano <>
This commit is contained in:
Taylor Blau 2023-05-01 11:53:48 -04:00 committed by Junio C Hamano
parent 48d89b51b3
commit 16b305cd2b
1 changed files with 2 additions and 0 deletions

View File

@ -238,6 +238,8 @@ int credential_read(struct credential *c, FILE *fp)
} else if (!strcmp(key, "path")) {
c->path = xstrdup(value);
} else if (!strcmp(key, "wwwauth[]")) {
strvec_push(&c->wwwauth_headers, value);
} else if (!strcmp(key, "password_expiry_utc")) {
errno = 0;
c->password_expiry_utc = parse_timestamp(value, NULL, 10);