git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Improvement to only call Git Credential Helper once

From
Kyle Hubert <khubert@gmail.com>
Date
Sep 28, 2018, 15:50 UTC
Message-ID
<CAJoZ4U1cKjbgYq3=S--KbV8Yhce83z1WhTQJHTFyBTRRe2-DHg@mail.gmail.com>
In-Reply-To
<CAJoZ4U2G5rhZnOxsHjxByfYQvDCc-CJ=1-JjyrjW_B-CWForEA@mail.gmail.com>
Sorry, this patch is damaged. I'm moving to `git send-email` now.
-Kyle
On Fri, Sep 28, 2018 at 11:10 AM Kyle Hubert <khubert@gmail.com> wrote:
Show 58 quoted lines
>
> When calling the Git Credential Helper that is set in the git config,
> the get command can return a credential. Git immediately turns around
> and calls the store command, even though that credential was just
> retrieved by the Helper. This creates two side effects. First of all,
> if the Helper requires a passphrase, the user has to type it in
> twice. Secondly, if the user has a number of helpers, this retrieves
> the credential from one service and writes it to all services.
>
> This commit introduces a new field in the credential struct that
> detects when the credential was retrieved using the Helper, and early
> exits when called to store the credential.
> ---
>  credential.c | 8 +++++++-
>  credential.h | 3 ++-
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/credential.c b/credential.c
> index 62be651b0..79bf62d49 100644
> --- a/credential.c
> +++ b/credential.c
> @@ -280,8 +280,10 @@ void credential_fill(struct credential *c)
>
>   for (i = 0; i < c->helpers.nr; i++) {
>   credential_do(c, c->helpers.items[i].string, "get");
> - if (c->username && c->password)
> + if (c->username && c->password) {
> + c->retrieved = 1;
>   return;
> + }
>   if (c->quit)
>   die("credential helper '%s' told us to quit",
>       c->helpers.items[i].string);
> @@ -300,6 +302,10 @@ void credential_approve(struct credential *c)
>   return;
>   if (!c->username || !c->password)
>   return;
> + if (c->retrieved) {
> + c->approved = 1;
> + return;
> + }
>
>   credential_apply_config(c);
>
> diff --git a/credential.h b/credential.h
> index 6b0cd16be..d99df2f52 100644
> --- a/credential.h
> +++ b/credential.h
> @@ -8,7 +8,8 @@ struct credential {
>   unsigned approved:1,
>   configured:1,
>   quit:1,
> - use_http_path:1;
> + use_http_path:1,
> + retrieved:1;
>
>   char *username;
>   char *password;
Previous: Kyle Hubert
Message 2 of 2 in “Improvement to only call Git Credential Helper once”
  1. Improvement to only call Git Credential Helper onceKyle Hubert, Sep 28, 2018
  2. Kyle HubertSep 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.