{"thread":{"id":"28474","subject":"[PATCH] credential-cache: don't cache items without context","startedAt":"2011-09-23T21:53:24Z","lastAt":"2011-09-23T21:53:24Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"176103","messageId":"20110923215324.GA3013@sigill.intra.peff.net","threadId":"28474","inReplyTo":null,"subject":"[PATCH] credential-cache: don't cache items without context","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-23T21:53:24Z","receivedAt":"2011-09-23T21:53:24Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The credential helper should get a --unique=<whatever>\ncontext from the callers.  It would be meaningless to cache\na username and password combination without being given any\ncontext, since we have no idea when we should use them\nagain. The current code will reuse them next time we have no\ncontext again, but that is probably not sane; there is no\nguarantee that it is the same \"lack of context\" situation.\n\nGit doesn't currently actually make requests of credential\nhelpers without a context, so this is a non-issue outside of\nspecialized testing. But it should do the sane thing given\nany input, and it's nice to set a good example for other\nhelpers (which may not be tied to a specific git version,\nand so arguments like \"git doesn't currently do this\" don't\napply to them).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nOn top of jk/http-auth-keyring, naturally.\n\n credential-cache.c |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/credential-cache.c b/credential-cache.c\nindex f495043..14d751e 100644\n--- a/credential-cache.c\n+++ b/credential-cache.c\n@@ -155,9 +155,11 @@ int main(int argc, const char **argv)\n \tprintf(\"username=%s\\n\", c.username);\n \tprintf(\"password=%s\\n\", c.password);\n \n-\tif (do_cache(socket_path, \"store\", &c, timeout) < 0) {\n-\t\tspawn_daemon(socket_path);\n-\t\tdo_cache(socket_path, \"store\", &c, timeout);\n+\tif (c.unique) {\n+\t\tif (do_cache(socket_path, \"store\", &c, timeout) < 0) {\n+\t\t\tspawn_daemon(socket_path);\n+\t\t\tdo_cache(socket_path, \"store\", &c, timeout);\n+\t\t}\n \t}\n \treturn 0;\n }\n-- \n1.7.7.rc2.4.ga9aee2.dirty\n"}]}