Skip to content

Commit

Permalink
git-p4: rewrite prompt to be Windows compatible
Browse files Browse the repository at this point in the history
The existing function prompt(prompt_text) does not work correctly when
run on Windows 10 bash terminal when launched from the sourcetree
GUI application. The stdout is not flushed properly so the prompt text
is not displayed to the user until the next flush of stdout, which is
quite confusing.

Change this method by:
* Adding flush to stderr, stdout, and stdin
* Use readline from sys.stdin instead of raw_input.

The existing strip().lower() are retained.

Signed-off-by: Ben Keene <seraphire@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
seraphire authored and gitster committed Feb 11, 2020
1 parent d0654dc commit 6b602a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion git-p4.py
Expand Up @@ -175,7 +175,10 @@ def prompt(prompt_text):
"""
choices = set(m.group(1) for m in re.finditer(r"\[(.)\]", prompt_text))
while True:
response = raw_input(prompt_text).strip().lower()
sys.stderr.flush()
sys.stdout.write(prompt_text)
sys.stdout.flush()
response=sys.stdin.readline().strip().lower()
if not response:
continue
response = response[0]
Expand Down

0 comments on commit 6b602a2

Please sign in to comment.