From: roucherj Date: Mon, 11 Jun 2012 19:14:00 GMT Subject: Re: [PATCH v3] add 'git credential' plumbing command Message-ID: <0425823888ed7e40d9332e148ac9e77a@telesun.imag.fr> In-Reply-To: <20120611210745.Horde.72y3YnwdC4BP1kIBup3BWrA@webmail.minatec.grenoble-inp.fr> On Mon, 11 Jun 2012 21:07:45 +0200, konglu@minatec.inpg.fr wrote: > Javier.Roucher-Iglesias@ensimag.imag.fr a écrit : > >> +Git-credential permits to the user of the script to save: >> +username, password, host, path and protocol. When the user of >> script >> +invoke git-credential, the script can ask for a password, using the >> command >> +'git credential fill'. >> +Taking data from the standard input, the program treats each line >> as a >> +separate data item, and the end of series of data item is signalled >> by a >> +blank line. >> + >> + username=admin\n >> + protocol=[http|https]\n >> + host=localhost\n >> + path=/dir\n\n >> + >> +-If git-credential system has the password already stored >> +git-credential will answer with by STDOUT: >> + >> + username=admin >> + password=***** >> + >> +-If it is not stored, the user will be prompt for a password: >> + >> + > Password for '[http|https]admin@localhost': > > Whitespaces detected (and also some more after in the doc) > >> diff --git a/builtin/credential.c b/builtin/credential.c >> new file mode 100644 >> index 0000000..a6b6962 >> --- /dev/null >> +++ b/builtin/credential.c >> @@ -0,0 +1,37 @@ >> +#include >> +#include "cache.h" >> +#include "credential.h" >> +#include "string-list.h" >> + >> +static const char usage_msg[] = >> +"credential "; >> + >> +void cmd_credential (int argc, char **argv, const char *prefix) { >> + const char *op; >> + struct credential c = CREDENTIAL_INIT; >> + int i; >> + >> + op = argv[1]; >> + if (!op) >> + usage(usage_msg); >> + >> + if (credential_read(&c, stdin) < 0) >> + die("unable to read credential from stdin"); >> + >> + if (!strcmp(op, "fill")) { >> + credential_fill(&c); >> + if (c.username) >> + printf("username=%s\n", c.username); >> + if (c.password) >> + printf("password=%s\n", c.password); >> + } >> + else if (!strcmp(op, "approve")) { >> + credential_approve(&c); >> + } >> + else if (!strcmp(op, "reject")) { >> + credential_reject(&c); >> + } >> + else { >> + usage(usage_msg); >> + } >> +} > > Structure: > > if (!strcmp(op, "fill")) { > credential_fill(&c); > if (c.username) > printf("username=%s\n", c.username); > if (c.password) > printf("password=%s\n", c.password); > } else if (!strcmp(op, "approve")) { > credential_approve(&c); > } else if (!strcmp(op, "reject")) { > credential_reject(&c); > } else { > usage(usage_msg); > } I will change the structure, thanks.