add 'git credential' plumbing command
[alt-git.git] / builtin / credential.c
blobc185c07a2296e816f211a021ed0339a192dc0115
1 #include "git-compat-util.h"
2 #include "credential.h"
3 #include "builtin.h"
5 static const char usage_msg[] =
6 "git credential [fill|approve|reject]";
8 int cmd_credential(int argc, const char **argv, const char *prefix)
10 const char *op;
11 struct credential c = CREDENTIAL_INIT;
13 op = argv[1];
14 if (!op)
15 usage(usage_msg);
17 if (credential_read(&c, stdin) < 0)
18 die("unable to read credential from stdin");
20 if (!strcmp(op, "fill")) {
21 credential_fill(&c);
22 if (c.username)
23 printf("username=%s\n", c.username);
24 if (c.password)
25 printf("password=%s\n", c.password);
26 } else if (!strcmp(op, "approve")) {
27 credential_approve(&c);
28 } else if (!strcmp(op, "reject")) {
29 credential_reject(&c);
30 } else {
31 usage(usage_msg);
33 return 0;