summaryrefslogtreecommitdiff
path: root/connect.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-12-10 10:40:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-12-13 00:09:38 (GMT)
commitd3c58b83aee2007ca76dc5d1242c09b6f7989c76 (patch)
tree29e79755987e0670a8258992c3a5cd504a445f9e /connect.c
parent6c597aeba1e0fc369e64b1033515b0e39544cbe1 (diff)
downloadgit-d3c58b83aee2007ca76dc5d1242c09b6f7989c76.zip
git-d3c58b83aee2007ca76dc5d1242c09b6f7989c76.tar.gz
git-d3c58b83aee2007ca76dc5d1242c09b6f7989c76.tar.bz2
move git_getpass to its own source file
This is currently in connect.c, but really has nothing to do with the git protocol itself. Let's make a new source file all about prompting the user, which will make it cleaner to refactor. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c44
1 files changed, 0 insertions, 44 deletions
diff --git a/connect.c b/connect.c
index 51990fa..519e527 100644
--- a/connect.c
+++ b/connect.c
@@ -619,47 +619,3 @@ int finish_connect(struct child_process *conn)
free(conn);
return code;
}
-
-char *git_getpass(const char *prompt)
-{
- const char *askpass;
- struct child_process pass;
- const char *args[3];
- static struct strbuf buffer = STRBUF_INIT;
-
- askpass = getenv("GIT_ASKPASS");
- if (!askpass)
- askpass = askpass_program;
- if (!askpass)
- askpass = getenv("SSH_ASKPASS");
- if (!askpass || !(*askpass)) {
- char *result = getpass(prompt);
- if (!result)
- die_errno("Could not read password");
- return result;
- }
-
- args[0] = askpass;
- args[1] = prompt;
- args[2] = NULL;
-
- memset(&pass, 0, sizeof(pass));
- pass.argv = args;
- pass.out = -1;
-
- if (start_command(&pass))
- exit(1);
-
- strbuf_reset(&buffer);
- if (strbuf_read(&buffer, pass.out, 20) < 0)
- die("failed to read password from %s\n", askpass);
-
- close(pass.out);
-
- if (finish_command(&pass))
- exit(1);
-
- strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));
-
- return buffer.buf;
-}