Skip to content

Commit c0578ae

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Temporarily back out compat/terminal.c changes
The "hack" to use `bash`'s `read -r` function to read reliably from `/dev/tty` conflicts with the upcoming built-in `add -p`, to support single key stroke commands. Let's back out the changes, and then re-apply them on top of `add -p`, consolidated. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ac4e8ca commit c0578ae

File tree

1 file changed

+0
-63
lines changed

1 file changed

+0
-63
lines changed

compat/terminal.c

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
#ifndef NO_INTTYPES_H
2-
#include <inttypes.h>
3-
#endif
41
#include "git-compat-util.h"
5-
#include "run-command.h"
62
#include "compat/terminal.h"
73
#include "sigchain.h"
84
#include "strbuf.h"
9-
#include "cache.h"
105

116
#if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)
127

@@ -96,55 +91,6 @@ static int disable_echo(void)
9691
return 0;
9792
}
9893

99-
static char *shell_prompt(const char *prompt, int echo)
100-
{
101-
const char *read_input[] = {
102-
/* Note: call 'bash' explicitly, as 'read -s' is bash-specific */
103-
"bash", "-c", echo ?
104-
"cat >/dev/tty && read -r line </dev/tty && echo \"$line\"" :
105-
"cat >/dev/tty && read -r -s line </dev/tty && echo \"$line\" && echo >/dev/tty",
106-
NULL
107-
};
108-
struct child_process child = CHILD_PROCESS_INIT;
109-
static struct strbuf buffer = STRBUF_INIT;
110-
int prompt_len = strlen(prompt), len = -1, code;
111-
112-
child.argv = read_input;
113-
child.in = -1;
114-
child.out = -1;
115-
child.silent_exec_failure = 1;
116-
117-
if (start_command(&child))
118-
return NULL;
119-
120-
if (write_in_full(child.in, prompt, prompt_len) != prompt_len) {
121-
error("could not write to prompt script");
122-
close(child.in);
123-
goto ret;
124-
}
125-
close(child.in);
126-
127-
strbuf_reset(&buffer);
128-
len = strbuf_read(&buffer, child.out, 1024);
129-
if (len < 0) {
130-
error("could not read from prompt script");
131-
goto ret;
132-
}
133-
134-
strbuf_strip_suffix(&buffer, "\n");
135-
strbuf_strip_suffix(&buffer, "\r");
136-
137-
ret:
138-
close(child.out);
139-
code = finish_command(&child);
140-
if (code) {
141-
error("failed to execute prompt script (exit code %d)", code);
142-
return NULL;
143-
}
144-
145-
return len < 0 ? NULL : buffer.buf;
146-
}
147-
14894
#endif
14995

15096
#ifndef FORCE_TEXT
@@ -157,15 +103,6 @@ char *git_terminal_prompt(const char *prompt, int echo)
157103
int r;
158104
FILE *input_fh, *output_fh;
159105

160-
#ifdef GIT_WINDOWS_NATIVE
161-
162-
/* try shell_prompt first, fall back to CONIN/OUT if bash is missing */
163-
char *result = shell_prompt(prompt, echo);
164-
if (result)
165-
return result;
166-
167-
#endif
168-
169106
input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT);
170107
if (!input_fh)
171108
return NULL;

0 commit comments

Comments
 (0)