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

Re: [PATCH 1/4] imap-send: add wrapper to get server credentials if needed

From
Jeff King <peff@peff.net>
Date
Aug 7, 2017, 19:42 UTC
Message-ID
<20170807194257.jrdmpvoseauz37uc@sigill.intra.peff.net>
In-Reply-To
<CAN0heSqVmrFwP7LdjDJmH0JivoCc+DhGtUiTSBs=8nTppzG79A@mail.gmail.com>
On Mon, Aug 07, 2017 at 07:18:32PM +0200, Martin Ågren wrote:
Show 16 quoted lines
> >> "cred.username" is checked further down, but now it will always be NULL,
> >> no?
> >
> > You're right I missed this.
> > Not sure if this is needed though.
> > From what I understand this means the username/password are store for the next access to credential. but in the current state, there is only one.
> > Maybe the credential_approved can be dropped ?
> 
> I'm no credentials-expert, but api-credentials.txt says this:
> 
> "Credential helpers are programs executed by Git to fetch or save
> credentials from and to long-term storage (where "long-term" is simply
> longer than a single Git process; e.g., credentials may be stored
> in-memory for a few minutes, or indefinitely on disk)."
> 
> So the calls to approve/reject probably do matter in some scenarios.

Right, this is important. credential_fill() may actually prompt the user, and we'd want to then pass along that credential for storage. Or the user may have changed their password, and the credential_reject() is the only thing that prevents us from trying an out-dated password over and over.

Show 9 quoted lines
> The current code is a bit non-obvious as we just discovered since it
> duplicates the strings (for good reasons, I believe) and then still
> refers to the originals (also for good reasons, I believe). I suppose
> your new function could be called like
> 
> server_fill_credential(&cred, srvc);
> 
> That should limit the impact of the change, but I'm not sure it's a
> brilliant interface. Just my 2c.

That would work. I'm also tempted to say that imap_server_conf could just store the "struct credential" inside it. We could even potentially drop its parallel user/pass fields to minimize confusion.

Once upon a time imap-send was a fork of another program, which is why most of its code isn't well-integrated with Git. But I think at this point there's very little chance of merging changes back and forth between the two.

On the other hand, if we're hoping to get rid of this code in favor of the curl-based approach, then it's not worth spending time on cosmetic refactoring, as long as it still behaves correctly in the interim.

-Peff
Previous: Martin ÅgrenNext: Nicolas Morey-Chaisemartin
Message 5 of 8 in “imap-send: add wrapper to get server credentials if needed”
  1. 1/4 imap-send: add wrapper to get server credentials if neededNicolas Morey-Chaisemartin, Aug 7, 2017
  2. Martin ÅgrenAug 7, 2017
  3. Nicolas Morey-ChaisemartinAug 7, 2017
  4. Martin ÅgrenAug 7, 2017
  5. Jeff KingAug 7, 2017
  6. Nicolas Morey-ChaisemartinAug 7, 2017
  7. Jeff KingAug 7, 2017
  8. Junio C HamanoAug 7, 2017

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.