Skip to content

Commit a509025

Browse files
peffgitster
authored andcommitted
prompt: use git_terminal_prompt
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 21aeafc commit a509025

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

prompt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "run-command.h"
33
#include "strbuf.h"
44
#include "prompt.h"
5+
#include "compat/terminal.h"
56

67
static char *do_askpass(const char *cmd, const char *prompt)
78
{
@@ -50,7 +51,7 @@ char *git_prompt(const char *prompt, int flags)
5051
return do_askpass(askpass, prompt);
5152
}
5253

53-
r = getpass(prompt);
54+
r = git_terminal_prompt(prompt, flags & PROMPT_ECHO);
5455
if (!r)
5556
die_errno("could not read '%s'", prompt);
5657
return r;

prompt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define PROMPT_H
33

44
#define PROMPT_ASKPASS (1<<0)
5+
#define PROMPT_ECHO (1<<1)
56

67
char *git_prompt(const char *prompt, int flags);
78
char *git_getpass(const char *prompt);

0 commit comments

Comments
 (0)