2012-06-24 11:39:59 +00:00
|
|
|
#include "git-compat-util.h"
|
2011-12-10 10:31:11 +00:00
|
|
|
#include "credential.h"
|
2012-06-24 11:39:59 +00:00
|
|
|
#include "builtin.h"
|
2020-10-15 21:59:20 +00:00
|
|
|
#include "config.h"
|
2011-12-10 10:31:11 +00:00
|
|
|
|
|
|
|
static const char usage_msg[] =
|
2021-10-28 16:21:56 +00:00
|
|
|
"git credential (fill|approve|reject)";
|
2011-12-10 10:31:11 +00:00
|
|
|
|
2012-06-24 11:39:59 +00:00
|
|
|
int cmd_credential(int argc, const char **argv, const char *prefix)
|
2011-12-10 10:31:11 +00:00
|
|
|
{
|
|
|
|
const char *op;
|
|
|
|
struct credential c = CREDENTIAL_INIT;
|
|
|
|
|
2020-10-15 21:59:20 +00:00
|
|
|
git_config(git_default_config, NULL);
|
|
|
|
|
2017-05-30 05:12:33 +00:00
|
|
|
if (argc != 2 || !strcmp(argv[1], "-h"))
|
2011-12-10 10:31:11 +00:00
|
|
|
usage(usage_msg);
|
2017-05-30 05:12:33 +00:00
|
|
|
op = argv[1];
|
2011-12-10 10:31:11 +00:00
|
|
|
|
|
|
|
if (credential_read(&c, stdin) < 0)
|
|
|
|
die("unable to read credential from stdin");
|
|
|
|
|
|
|
|
if (!strcmp(op, "fill")) {
|
|
|
|
credential_fill(&c);
|
2012-06-24 11:40:00 +00:00
|
|
|
credential_write(&c, stdout);
|
2012-06-24 11:39:59 +00:00
|
|
|
} else if (!strcmp(op, "approve")) {
|
2011-12-10 10:31:11 +00:00
|
|
|
credential_approve(&c);
|
2012-06-24 11:39:59 +00:00
|
|
|
} else if (!strcmp(op, "reject")) {
|
2011-12-10 10:31:11 +00:00
|
|
|
credential_reject(&c);
|
2012-06-24 11:39:59 +00:00
|
|
|
} else {
|
2011-12-10 10:31:11 +00:00
|
|
|
usage(usage_msg);
|
2012-06-24 11:39:59 +00:00
|
|
|
}
|
2011-12-10 10:31:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|