Skip to content

Commit

Permalink
prompt: use git_terminal_prompt
Browse files Browse the repository at this point in the history
Our custom implementation of git_terminal_prompt has many
advantages over regular getpass(), as described in the prior
commit.

This also lets us implement a PROMPT_ECHO flag for callers
who want it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Dec 13, 2011
1 parent 21aeafc commit a509025
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion prompt.c
Expand Up @@ -2,6 +2,7 @@
#include "run-command.h"
#include "strbuf.h"
#include "prompt.h"
#include "compat/terminal.h"

static char *do_askpass(const char *cmd, const char *prompt)
{
Expand Down Expand Up @@ -50,7 +51,7 @@ char *git_prompt(const char *prompt, int flags)
return do_askpass(askpass, prompt);
}

r = getpass(prompt);
r = git_terminal_prompt(prompt, flags & PROMPT_ECHO);
if (!r)
die_errno("could not read '%s'", prompt);
return r;
Expand Down
1 change: 1 addition & 0 deletions prompt.h
Expand Up @@ -2,6 +2,7 @@
#define PROMPT_H

#define PROMPT_ASKPASS (1<<0)
#define PROMPT_ECHO (1<<1)

char *git_prompt(const char *prompt, int flags);
char *git_getpass(const char *prompt);
Expand Down

0 comments on commit a509025

Please sign in to comment.