]> git.ipfire.org Git - thirdparty/git.git/blame - builtin/credential.c
Merge branch 'fc/t6030-bisect-reset-removes-auxiliary-files' into maint
[thirdparty/git.git] / builtin / credential.c
CommitLineData
e30b2feb 1#include "git-compat-util.h"
abca927d 2#include "credential.h"
e30b2feb 3#include "builtin.h"
567ad2c0 4#include "config.h"
abca927d
JK
5
6static const char usage_msg[] =
e30b2feb 7 "git credential [fill|approve|reject]";
abca927d 8
e30b2feb 9int cmd_credential(int argc, const char **argv, const char *prefix)
abca927d
JK
10{
11 const char *op;
12 struct credential c = CREDENTIAL_INIT;
abca927d 13
567ad2c0
TK
14 git_config(git_default_config, NULL);
15
42fa0cbf 16 if (argc != 2 || !strcmp(argv[1], "-h"))
abca927d 17 usage(usage_msg);
42fa0cbf 18 op = argv[1];
abca927d
JK
19
20 if (credential_read(&c, stdin) < 0)
21 die("unable to read credential from stdin");
22
23 if (!strcmp(op, "fill")) {
24 credential_fill(&c);
2d6dc182 25 credential_write(&c, stdout);
e30b2feb 26 } else if (!strcmp(op, "approve")) {
abca927d 27 credential_approve(&c);
e30b2feb 28 } else if (!strcmp(op, "reject")) {
abca927d 29 credential_reject(&c);
e30b2feb 30 } else {
abca927d 31 usage(usage_msg);
e30b2feb 32 }
abca927d
JK
33 return 0;
34}