{"thread":{"id":"62081","subject":"[PATCH] config.mak.uname: add HAVE_DEV_TTY to cygwin config section","startedAt":"2024-09-09T01:27:01Z","lastAt":"2024-09-09T07:08:41Z","messageCount":2,"participants":["Ramsay Jones","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"502418","messageId":"e3339b4d-dab1-4247-b70e-d3224bab1b6b@ramsayjones.plus.com","threadId":"62081","inReplyTo":null,"subject":"[PATCH] config.mak.uname: add HAVE_DEV_TTY to cygwin config section","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2024-09-09T01:23:48Z","receivedAt":"2024-09-09T01:27:01Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nIf neither HAVE_DEV_TTY nor GIT_WINDOWS_NATIVE is set, while compiling\nthe 'compat/terminal.c' code, then the fallback code calls the system\ngetpass() function. Unfortunately, this ignores the 'echo' parameter of\nthe git_terminal_prompt() function, since it has no way to implement that\nfunctionality. This results in a less than optimal user experience on\ncygwin, which does not define either of those build flags.\n\nHowever, cygwin does have a functional '/dev/tty', so that it can build\nwith HAVE_DEV_TTY and benefit from the improved user experience.\n\nThe improved git_terminal_prompt() function that comes with HAVE_DEV_TTY\nis used in the git_prompt() function, which in turn is used by the\n'git credential', 'git bisect' and 'git help' commands. In addition to\ngit_terminal_prompt(), read_key_without_echo() is likewise improved and\nused by the 'git add -p' command.\n\nWhile using the 'git credential fill' command, for example:\n\n  $ printf \"%s\\n\" protocol=https host=example.com path=git | ./git credential fill\n  Username for 'https://example.com': user\n  Password for 'https://user@example.com':\n  protocol=https\n  host=example.com\n  username=user\n  password=pass\n  $\n\nThe 'user' name is now echoed while typing (the password isn't), where this\nwasn't the case before.\n\nWhen using the auto-correct feature:\n\n  $ ./git -c help.autocorrect=prompt fred\n  WARNING: You called a Git command named 'fred', which does not exist.\n  Run 'grep' instead [y/N]? n\n  $ ./git -c help.autocorrect=prompt fred\n  WARNING: You called a Git command named 'fred', which does not exist.\n  Run 'grep' instead [y/N]? y\n  fatal: no pattern given\n  $\n\nThe user can actually see what they are typing at the prompt. Similar\ncomments apply to 'git bisect':\n\n  $ ./git bisect bad master~1\n  You need to start by \"git bisect start\"\n\n  Do you want me to do it for you [Y/n]? y\n  status: waiting for both good and bad commits\n  status: waiting for good commit(s), bad commit known\n  $ ./git bisect reset\n  Already on 'master-tmp'\n  $\n\n  $ ./git bisect start\n  status: waiting for both good and bad commits\n  $ ./git bisect bad master~1\n  status: waiting for good commit(s), bad commit known\n  $ ./git bisect next\n  warning: bisecting only with a bad commit\n  Are you sure [Y/n]? n\n  $ ./git bisect reset\n  Already on 'master-tmp'\n  $\n\nThe read_key_without_echo() function leads to a much improved 'git add -p'\ncommand, when the 'interactive.singleKey' configuration is set:\n\n  $ cd ..\n  $ mkdir test-git\n  $ cd test-git\n  $ git init -q\n  $ echo foo >file\n  $ git add file\n  $ echo bar >file\n  $ ../git/git -c interactive.singleKey=true add -p\n  diff --git a/file b/file\n  index 257cc56..5716ca5 100644\n  --- a/file\n  +++ b/file\n  @@ -1 +1 @@\n  -foo\n  +bar\n  (1/1) Stage this hunk [y,n,q,a,d,e,p,?]? y\n\n  $\n\nNote that, not only is the user input echoed, but that it is immediately\naccepted (without having to type <return>) and the program exits with the\nhunk staged (in this case) or not.\n\nIn order to reap these benefits, set the HAVE_DEV_TTY build flag in the\ncygwin configuration section of config.mak.uname.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Junio,\n\nAfter more testing, I removed the RFC from this patch and actually wrote\na commit message. (I wasn't sure if I should mark this with v2 as well?).\n\nI was a bit surprised that this went unnoticed for so long, but I don't\nuse 'git credential' (shh-agent is all I need), 'git add -p' (vim works\nfor me!) or used the help.autocorrect=prompt. I have used 'git bisect'\nmany, many times (of course), but I don't recall ever seeing either of\nthose prompts! This goes for Linux as well as cygwin. :)\n\nATB,\nRamsay Jones\n\n config.mak.uname | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 904bcf3598..d5112168a4 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -248,6 +248,7 @@ ifeq ($(uname_O),Cygwin)\n         else\n \t\tNO_REGEX = UnfortunatelyYes\n         endif\n+\tHAVE_DEV_TTY = YesPlease\n \tHAVE_ALLOCA_H = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n-- \n2.46.0\n"},{"id":"502421","messageId":"20240909070836.GA4050065@coredump.intra.peff.net","threadId":"62081","inReplyTo":"e3339b4d-dab1-4247-b70e-d3224bab1b6b@ramsayjones.plus.com","subject":"Re: [PATCH] config.mak.uname: add HAVE_DEV_TTY to cygwin config section","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-09-09T07:08:36Z","receivedAt":"2024-09-09T07:08:41Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Sep 09, 2024 at 02:23:48AM +0100, Ramsay Jones wrote:\n\n> After more testing, I removed the RFC from this patch and actually wrote\n> a commit message. (I wasn't sure if I should mark this with v2 as well?).\n> \n> I was a bit surprised that this went unnoticed for so long, but I don't\n> use 'git credential' (shh-agent is all I need), 'git add -p' (vim works\n> for me!) or used the help.autocorrect=prompt. I have used 'git bisect'\n> many, many times (of course), but I don't recall ever seeing either of\n> those prompts! This goes for Linux as well as cygwin. :)\n\nThe patch unsurprisingly looks good to me.\n\nI think most of what you are describing in the commit message is all the\nnormal and expected benefits of HAVE_DEV_TTY. :) But I don't mind erring\non the side of over-explaining there.\n\n-Peff\n"}]}