* Re: [PATCH v2 0/2] Explicitly fflush stdout in git clean
@ 2020-04-10 12:46 Lia Rosas
0 siblings, 0 replies; 2+ messages in thread
From: Lia Rosas @ 2020-04-10 12:46 UTC (permalink / raw)
To: gitgitgadget; +Cc: git, johannes.schindelin, peff
Sent from my iPhone
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] clean: explicitly `fflush` stdout
@ 2020-04-08 19:33 Johannes Schindelin via GitGitGadget
2020-04-10 11:27 ` [PATCH v2 0/2] Explicitly fflush stdout in git clean Johannes Schindelin via GitGitGadget
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-04-08 19:33 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, 마누엘
From: =?UTF-8?q?=EB=A7=88=EB=88=84=EC=97=98?= <nalla@hamal.uberspace.de>
For performance reasons `stdout` is buffered by default. That leads to
problems if after printing to `stdout` a read on `stdin` is performed.
For that reason interactive commands like `git clean -i` do not function
properly anymore if the `stdout` is not flushed by `fflush(stdout)` before
trying to read from `stdin`.
So let's precede all reads on `stdin` in `git clean -i` by flushing
`stdout`.
Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Explicitly fflush stdout in git clean
This is yet another patch that was funneled through a Git for Windows
PR. It has served us well for almost five years now, and it is beyond
time that it find its final home in core Git.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-755%2Fdscho%2Ffflush-in-git-clean-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-755/dscho/fflush-in-git-clean-v1
Pull-Request: https://github.com/git/git/pull/755
builtin/clean.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/builtin/clean.c b/builtin/clean.c
index 5abf087e7c4..2bd06d13395 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -580,6 +580,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
clean_get_color(CLEAN_COLOR_RESET));
}
+ fflush(stdout);
if (strbuf_getline_lf(&choice, stdin) != EOF) {
strbuf_trim(&choice);
} else {
@@ -662,6 +663,7 @@ static int filter_by_patterns_cmd(void)
clean_print_color(CLEAN_COLOR_PROMPT);
printf(_("Input ignore patterns>> "));
clean_print_color(CLEAN_COLOR_RESET);
+ fflush(stdout);
if (strbuf_getline_lf(&confirm, stdin) != EOF)
strbuf_trim(&confirm);
else
@@ -760,6 +762,7 @@ static int ask_each_cmd(void)
qname = quote_path_relative(item->string, NULL, &buf);
/* TRANSLATORS: Make sure to keep [y/N] as is */
printf(_("Remove %s [y/N]? "), qname);
+ fflush(stdout);
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
strbuf_trim(&confirm);
} else {
base-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775
--
gitgitgadget
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v2 0/2] Explicitly fflush stdout in git clean
2020-04-08 19:33 [PATCH] clean: explicitly `fflush` stdout Johannes Schindelin via GitGitGadget
@ 2020-04-10 11:27 ` Johannes Schindelin via GitGitGadget
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2020-04-10 11:27 UTC (permalink / raw)
To: git; +Cc: Jeff King, Johannes Schindelin
This is yet another patch that was funneled through a Git for Windows PR,
read: it has been battle-tested.
Of course, the current iteration of this patch series has not been
battle-tested, so please do review carefully, so that we can prevent bugs
from slipping in during the review process.
Changes since v1:
* Added a preparatory patch that refactors all interactive input reading
via strbuf_getline(..., stdin).
* Adjusted the patch and its commit message accordingly.
Johannes Schindelin (1):
Refactor code asking the user for input interactively
마누엘 (1):
Explicitly `fflush` stdout before expecting interactive input
add-interactive.c | 4 ++--
add-patch.c | 4 ++--
builtin/clean.c | 14 ++++----------
prompt.c | 12 ++++++++++++
prompt.h | 2 ++
shell.c | 4 ++--
6 files changed, 24 insertions(+), 16 deletions(-)
base-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-755%2Fdscho%2Ffflush-in-git-clean-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-755/dscho/fflush-in-git-clean-v2
Pull-Request: https://github.com/git/git/pull/755
Range-diff vs v1:
1: 21acd883b94 < -: ----------- clean: explicitly `fflush` stdout
-: ----------- > 1: 9d2ee78a9e4 Refactor code asking the user for input interactively
-: ----------- > 2: d3949e42004 Explicitly `fflush` stdout before expecting interactive input
--
gitgitgadget
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-10 12:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 12:46 [PATCH v2 0/2] Explicitly fflush stdout in git clean Lia Rosas
-- strict thread matches above, loose matches on Subject: below --
2020-04-08 19:33 [PATCH] clean: explicitly `fflush` stdout Johannes Schindelin via GitGitGadget
2020-04-10 11:27 ` [PATCH v2 0/2] Explicitly fflush stdout in git clean Johannes Schindelin via GitGitGadget
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.