]> git.ipfire.org Git - thirdparty/git.git/blame - builtin/credential.c
credential: gate new fields on capability
[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[] =
b7bf32b0 7 "git credential (fill|approve|reject)";
abca927d 8
5247b762 9int cmd_credential(int argc, const char **argv, const char *prefix UNUSED)
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 19
ca9ccbf6 20 if (credential_read(&c, stdin, CREDENTIAL_OP_INITIAL) < 0)
abca927d
JK
21 die("unable to read credential from stdin");
22
23 if (!strcmp(op, "fill")) {
ca9ccbf6 24 credential_fill(&c, 0);
25 credential_write(&c, stdout, CREDENTIAL_OP_RESPONSE);
e30b2feb 26 } else if (!strcmp(op, "approve")) {
ca9ccbf6 27 credential_set_all_capabilities(&c, CREDENTIAL_OP_HELPER);
abca927d 28 credential_approve(&c);
e30b2feb 29 } else if (!strcmp(op, "reject")) {
ca9ccbf6 30 credential_set_all_capabilities(&c, CREDENTIAL_OP_HELPER);
abca927d 31 credential_reject(&c);
e30b2feb 32 } else {
abca927d 33 usage(usage_msg);
e30b2feb 34 }
abca927d
JK
35 return 0;
36}