Skip to content

Commit cad52c8

Browse files
committed
fixup! mingw (git_terminal_prompt): turn on echo explictly
The `add -p` changes conflict with this commit, so let's revert it for now. Besides, it would appear that the rationale of the change is not sound: in a quick test in a PowerShell, it seems that echo *is* the default. To verify, test, run this in a PowerShell session: git -c alias.s="! unset GIT_CONFIG_PARAMETERS; printf `"hostname=123\\n\\n`" | GIT_ASKPASS= ./git \ -c credential.helper= --exec-path=`$PWD credential fill " s This reverts commit b9990a3. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent dc2ae9a commit cad52c8

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

compat/terminal.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,17 @@ static void restore_term(void)
7777
hconin = INVALID_HANDLE_VALUE;
7878
}
7979

80-
static int set_echo(int echo)
80+
static int disable_echo(void)
8181
{
82-
DWORD new_cmode;
83-
84-
if (hconin == INVALID_HANDLE_VALUE)
85-
hconin = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE,
86-
FILE_SHARE_READ, NULL, OPEN_EXISTING,
87-
FILE_ATTRIBUTE_NORMAL, NULL);
82+
hconin = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE,
83+
FILE_SHARE_READ, NULL, OPEN_EXISTING,
84+
FILE_ATTRIBUTE_NORMAL, NULL);
8885
if (hconin == INVALID_HANDLE_VALUE)
8986
return -1;
9087

9188
GetConsoleMode(hconin, &cmode);
92-
new_cmode = cmode | ENABLE_LINE_INPUT;
93-
if (echo)
94-
new_cmode |= ENABLE_ECHO_INPUT;
95-
else
96-
new_cmode &= ~ENABLE_ECHO_INPUT;
97-
9889
sigchain_push_common(restore_term_on_signal);
99-
if (!SetConsoleMode(hconin, new_cmode)) {
90+
if (!SetConsoleMode(hconin, cmode & (~ENABLE_ECHO_INPUT))) {
10091
CloseHandle(hconin);
10192
hconin = INVALID_HANDLE_VALUE;
10293
return -1;
@@ -105,11 +96,6 @@ static int set_echo(int echo)
10596
return 0;
10697
}
10798

108-
static int disable_echo(void)
109-
{
110-
return set_echo(0);
111-
}
112-
11399
static char *shell_prompt(const char *prompt, int echo)
114100
{
115101
const char *read_input[] = {
@@ -183,8 +169,6 @@ char *git_terminal_prompt(const char *prompt, int echo)
183169
if (result)
184170
return result;
185171

186-
if (echo && set_echo(1))
187-
return NULL;
188172
#endif
189173

190174
input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);

0 commit comments

Comments
 (0)