Javier.Roucher-Iglesias@xxxxxxxxxxxxxxx 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 <stdio.h> +#include "cache.h" +#include "credential.h" +#include "string-list.h" + +static const char usage_msg[] = +"credential <fill|approve|reject>"; + +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); } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html