git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] Refactor code asking the user for input interactively

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 10, 2020, 17:44 UTC
Message-ID
<xmqqftdbjkv8.fsf@gitster.c.googlers.com>
In-Reply-To
<9d2ee78a9e414c0b6aacbc9c878ab08eb70703d5.1586518072.git.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

> -		if (strbuf_getline(&input, stdin) == EOF) {
> +		if (git_read_line_interactively(&input) == EOF) {

It's not like we are mimicking or giving a thin wrapper to improve an existing read_line_interactively() from a third-party, so I do not see much point in giving "git_" prefix here. On the other hand, "strbuf_" prefix may not hurt (but the type of its first parameter is sufficient so it is not exactly required).

Show 7 quoted lines
>  			printf(_("Remove %s [y/N]? "), qname);
> -			if (strbuf_getline_lf(&confirm, stdin) != EOF) {
> -				strbuf_trim(&confirm);
> -			} else {
> +			if (git_read_line_interactively(&confirm) == EOF) {
>  				putchar('\n');
>  				eof = 1;

A fat-finger that gave an answer " yes <RET>" used to be still taken as a yes but now it is interpreted as "no", because the new helper trims a lot less. In general, the existing code should be already choosing the safer default, so such a change in behaviour brought in by this change, even if they were not intentional, should probably be safe.

Thanks.
Previous: Jeff KingNext: 마누엘 via GitGitGadget
Message 11 of 16 in “clean: explicitly `fflush` stdout”
  1. clean: explicitly `fflush` stdoutJohannes Schindelin via GitGitGadget, Apr 8, 2020
  2. Jeff KingApr 8, 2020
  3. Junio C HamanoApr 8, 2020
  4. Jeff KingApr 8, 2020
  5. Johannes SchindelinApr 10, 2020
  6. 0/2 Explicitly fflush stdout in git cleanJohannes Schindelin via GitGitGadget, Apr 10, 2020
  7. 1/2 Refactor code asking the user for input interactivelyJohannes Schindelin via GitGitGadget, Apr 10, 2020
  8. Derrick StoleeApr 10, 2020
  9. Johannes SchindelinApr 10, 2020
  10. Jeff KingApr 10, 2020
  11. Junio C HamanoApr 10, 2020
  12. 2/2 Explicitly `fflush` stdout before expecting interactive input마누엘 via GitGitGadget, Apr 10, 2020
  13. Derrick StoleeApr 10, 2020
  14. 0/2 Explicitly fflush stdout in git cleanJohannes Schindelin via GitGitGadget, Apr 10, 2020
  15. 1/2 Refactor code asking the user for input interactivelyJohannes Schindelin via GitGitGadget, Apr 10, 2020
  16. 2/2 Explicitly `fflush` stdout before expecting interactive input마누엘 via GitGitGadget, Apr 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.