pickaxe: assert that we must have a needle under -G or -S
[git/debian.git] / builtin / credential.c
blobd75dcdc64aa3c3da303b117ba505ba683c1afcde
1 #include "git-compat-util.h"
2 #include "credential.h"
3 #include "builtin.h"
4 #include "config.h"
6 static const char usage_msg[] =
7 "git credential [fill|approve|reject]";
9 int cmd_credential(int argc, const char **argv, const char *prefix)
11 const char *op;
12 struct credential c = CREDENTIAL_INIT;
14 git_config(git_default_config, NULL);
16 if (argc != 2 || !strcmp(argv[1], "-h"))
17 usage(usage_msg);
18 op = argv[1];
20 if (credential_read(&c, stdin) < 0)
21 die("unable to read credential from stdin");
23 if (!strcmp(op, "fill")) {
24 credential_fill(&c);
25 credential_write(&c, stdout);
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;