From 59b386526a6cdd0289cdf35dd8038ae1bdfd630f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 3 Dec 2014 22:46:48 -0500 Subject: credential: let helpers tell us to quit When we are trying to fill a credential, we loop over the set of defined credential-helpers, then fall back to running askpass, and then finally prompt on the terminal. Helpers which cannot find a credential are free to tell us nothing, but they cannot currently ask us to stop prompting. This patch lets them provide a "quit" attribute, which asks us to stop the process entirely (avoiding running more helpers, as well as the askpass/terminal prompt). This has a few possible uses: 1. A helper which prompts the user itself (e.g., in a dialog) can provide a "cancel" button to the user to stop further prompts. 2. Some helpers may know that prompting cannot possibly work. For example, if their role is to broker a ticket from an external auth system and that auth system cannot be contacted, there is no point in continuing (we need a ticket to authenticate, and the user cannot provide one by typing it in). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- credential.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'credential.c') diff --git a/credential.c b/credential.c index 4d79d320f..0f974f198 100644 --- a/credential.c +++ b/credential.c @@ -173,6 +173,8 @@ int credential_read(struct credential *c, FILE *fp) c->path = xstrdup(value); } else if (!strcmp(key, "url")) { credential_from_url(c, value); + } else if (!strcmp(key, "quit")) { + c->quit = !!git_config_bool("quit", value); } /* * Ignore other lines; we don't know what they mean, but @@ -275,6 +277,9 @@ void credential_fill(struct credential *c) credential_do(c, c->helpers.items[i].string, "get"); if (c->username && c->password) return; + if (c->quit) + die("credential helper '%s' told us to quit", + c->helpers.items[i].string); } credential_getpass(c); -- cgit v1.2.1