1 #define USE_THE_REPOSITORY_VARIABLE
3 #include "git-compat-util.h"
4 #include "credential.h"
8 static const char usage_msg
[] =
9 "git credential (fill|approve|reject)";
11 int cmd_credential(int argc
,
13 const char *prefix UNUSED
,
14 struct repository
*repo UNUSED
)
17 struct credential c
= CREDENTIAL_INIT
;
19 git_config(git_default_config
, NULL
);
21 if (argc
!= 2 || !strcmp(argv
[1], "-h"))
25 if (!strcmp(op
, "capability")) {
26 credential_set_all_capabilities(&c
, CREDENTIAL_OP_INITIAL
);
27 credential_announce_capabilities(&c
, stdout
);
31 if (credential_read(&c
, stdin
, CREDENTIAL_OP_INITIAL
) < 0)
32 die("unable to read credential from stdin");
34 if (!strcmp(op
, "fill")) {
35 credential_fill(&c
, 0);
36 credential_next_state(&c
);
37 credential_write(&c
, stdout
, CREDENTIAL_OP_RESPONSE
);
38 } else if (!strcmp(op
, "approve")) {
39 credential_set_all_capabilities(&c
, CREDENTIAL_OP_HELPER
);
40 credential_approve(&c
);
41 } else if (!strcmp(op
, "reject")) {
42 credential_set_all_capabilities(&c
, CREDENTIAL_OP_HELPER
);
43 credential_reject(&c
);