Post 2.3 cycle (batch #3)
[gitweb.git] / credential.c
index 4d79d320f89e956aa9233a170120f05b2473ca59..b146ad8481b133892a542691c7e36f5e7974cfdc 100644 (file)
@@ -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
@@ -205,11 +207,10 @@ static int run_credential_helper(struct credential *c,
                                 const char *cmd,
                                 int want_output)
 {
-       struct child_process helper;
+       struct child_process helper = CHILD_PROCESS_INIT;
        const char *argv[] = { NULL, NULL };
        FILE *fp;
 
-       memset(&helper, 0, sizeof(helper));
        argv[0] = cmd;
        helper.argv = argv;
        helper.use_shell = 1;
@@ -275,6 +276,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);