mirror of
https://github.com/git/git.git
synced 2026-03-14 18:59:04 +01:00
This just does the normal "ask on the terminal, or use GIT_ASKPASS" logic that we already do. But it's useful for writers of third-party helpers. See the documentation for an example. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
38 lines
919 B
C
38 lines
919 B
C
#include "cache.h"
|
|
#include "credential.h"
|
|
#include "parse-options.h"
|
|
#include "string-list.h"
|
|
|
|
int main(int argc, const char **argv)
|
|
{
|
|
const char * const usage[] = {
|
|
"git credential-getpass [options]",
|
|
NULL
|
|
};
|
|
struct credential c = { NULL };
|
|
int reject = 0;
|
|
struct option options[] = {
|
|
OPT_BOOLEAN(0, "reject", &reject,
|
|
"reject a stored credential"),
|
|
OPT_STRING(0, "username", &c.username, "name",
|
|
"an existing username"),
|
|
OPT_STRING(0, "description", &c.description, "desc",
|
|
"human-readable description of the credential"),
|
|
OPT_STRING(0, "unique", &c.unique, "token",
|
|
"a unique context for the credential"),
|
|
OPT_END()
|
|
};
|
|
|
|
argc = parse_options(argc, argv, NULL, options, usage, 0);
|
|
if (argc)
|
|
usage_with_options(usage, options);
|
|
|
|
if (reject)
|
|
return 0;
|
|
|
|
credential_getpass(&c);
|
|
printf("username=%s\n", c.username);
|
|
printf("password=%s\n", c.password);
|
|
return 0;
|
|
}
|