define a structure for object IDs
[gitweb.git] / credential.c
index e54753c75d1c2abf7916f1aa7075d4ada3cfc61f..b146ad8481b133892a542691c7e36f5e7974cfdc 100644 (file)
@@ -40,8 +40,7 @@ static int credential_config_callback(const char *var, const char *value,
        struct credential *c = data;
        const char *key, *dot;
 
-       key = skip_prefix(var, "credential.");
-       if (!key)
+       if (!skip_prefix(var, "credential.", &key))
                return 0;
 
        if (!value)
@@ -174,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
@@ -206,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;
@@ -276,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);